본문 바로가기
코스웨어/13년 스마트컨트롤러

어셈블리 숙제 0828 - 임기준

by 알 수 없는 사용자 2013. 8. 28.
728x90
반응형

1번 문제

.386

.MODEL FLAT


ExitProcess PROTO NEAR32 stdcall, dxExitCode:DWORD


include io.h


cr equ 0dh

Lf equ 0ah


.STACK 4096


.DATA

Prompt1 BYTE "This program will evaluate the expression", cr,Lf,Lf

BYTE " 2 ( -x + y - 1 ) + z",cr,Lf,Lf

BYTE "for your choice of integer values.",cr,Lf,Lf

BYTE "Enter value for x: ", 0

Prompt2 BYTE "Enter value for y: ", 0

Prompt3 BYTE "Enter value for z: ", 0

Value BYTE 16 DUP (?)

Answer BYTE cr,Lf,"The result is "

Result BYTE 6 DUP (?)

BYTE cr,Lf,0


.CODE

_smart:

output Prompt1

input Value,16

atod Value

mov edx, eax

neg edx


output Prompt2

input Value,16

atod Value

add edx, eax

dec edx

add edx, edx


output Prompt3

input Value,16

atod Value

add edx, eax


dtoa Result, edx


output Answer


INVOKE   ExitProcess, 0

        

PUBLIC  _smart


END

2번 문제

.386

.MODEL FLAT


ExitProcess PROTO NEAR32 stdcall, dxExitCode:DWORD


include io.h


cr equ 0dh

Lf equ 0ah


.STACK 4096


.DATA

prompt1 BYTE "This program will find the area of a rectangle",cr,Lf,Lf

BYTE "Width of rectangle? ",0

prompt2 BYTE "Length of rectangle? ",0

value BYTE 16 DUP (?)

answer BYTE cr,Lf,"The area of the rectangle is "

area BYTE 11 DUP (?)

BYTE cr,Lf,0


.CODE

_smart:

output prompt1

input value, 16

atod value

mov ebx, eax

output prompt2

input value, 16

atod value

mul ebx

dtoa area, eax

output answer

INVOKE   ExitProcess, 0

        

PUBLIC  _smart


END



3번 문제

.386

.MODEL FLAT


ExitProcess PROTO NEAR32 stdcall, dxExitCode:DWORD


include io.h


cr equ 0dh

Lf equ 0ah


.STACK 4096


.DATA

prompt1 BYTE "This program will find the area of a box",cr,Lf,Lf

BYTE "Width of box? ",0

prompt2 BYTE "Length of box? ",0

prompt3 BYTE "Height of box? ",0

value BYTE 16 DUP (?)

answer BYTE cr,Lf,"The area of a box is "

area BYTE 11 DUP (?)

BYTE cr,Lf,0


.CODE

_smart:

output prompt1

input value, 16

atod value

mov ebx, eax ;ebx = Length


output prompt2

input value, 16

atod value

mov ecx, eax ;ecx = Width

mov edx, eax

imul edx, ebx ;edx = Length * Width


output prompt3

input value, 16

atod value

imul ebx, eax ;ebx = Length * Height, eax = Height

imul eax, ecx ;eax = Width * Height


add eax, ebx

add eax, edx


shl eax, 1


dtoa area, eax

output answer

INVOKE   ExitProcess, 0

        

PUBLIC  _smart


END




728x90