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

어셈블리 과제 - 조유진

by 알 수 없는 사용자 2013. 9. 2.
728x90
반응형

과제 1

.386

.MODEL FLAT


ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD


INCLUDE io.h


cr EQU 0dh

Lf EQU 0ah


.STACK 4096


.DATA

Prompt1 BYTE CR, LF, "This program will convert a Celsius "

BYTE "temperature to the Fahrenheit scale", cr, Lf, Lf

BYTE "Enter Celsius temperature : ", 0

Value BYTE 10 DUP ( ? )

Answer BYTE cr, Lf, "The temperature is"

Temperature BYTE 6 DUP ( ? )

BYTE " Fahrenheit", cr, Lf, 0


.CODE


_start:

Prompt:

output Prompt1

input Value, 10

atoi Value


imul ax, 9

add ax, 2

mov bx, 5

;cwd

idiv bx

add ax, 32


itoa Temperature, ax

output Answer


INVOKE ExitProcess, 0


PUBLIC _start

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 "Please enter Fahrenheit temperature to change in Celsius. : ", 0

Prompt2 BYTE cr, Lf, "The value "

Fahrenheit BYTE 6 DUP (?)

Prompt3 BYTE " Fahrenheit is "

Celsius BYTE 6 DUP (?)

BYTE " Celsius.", cr, Lf, 0


.CODE

_start:

output Prompt1

input Fahrenheit, 10

atoi Fahrenheit ; ax


sub ax, 32 ; ax = ax - 32

mov bx, ax ; bx = ax

mov cx, ax ; cx = ax


mov ax, 5 ; ax = 5


cwd


imul ax, cx


cwd


mov cx, 9


idiv cx


itoa Celsius, ax


output Prompt2


output Prompt3


INVOKE   ExitProcess, 0

        

PUBLIC  _start


END


728x90