화씨의 온도를 입력받아 섭씨 온도로 출력하기
C = (5/9) * (F-32)
소스.
.386
.MODEL FLAT
;1. The formula for converting a Fahrenheit to a Celsius temperature is
;C = (F - 32) * (5 / 9)
;Write a complete 80x86 assembly language program to prompt for a
;Fahrenheit temperature and display the corresponding Celsius temperature.
ExitProcess PROTO NEAR32 stdcall, dxExitCode: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 temperature scale", cr, Lf, Lf
BYTE "Enter Celsius Fahrenheit: ", 0
value BYTE 10 DUP (?)
answer BYTE cr, Lf, "The temperature is"
Fahrenheit BYTE 6 DUP (?)
BYTE " temperature", cr, Lf, 0
.CODE
_smart:
output prompt1 ; prompt for Celsius temperature
input value, 10 ; read ASCII characters
atoi value ; convert to integer
sub ax, 32
mov bx, 9
cwd
idiv bx
imul ax, 5
itoa Fahrenheit, ax
output answer
INVOKE ExitProcess, 0
PUBLIC _smart
실행 결과
'코스웨어 > 13년 스마트컨트롤러' 카테고리의 다른 글
switch 문 분석하기 (0) | 2013.09.04 |
---|---|
어셈블리 숙제 조유진 (0) | 2013.09.04 |
9월 4일 어셈블리 숙제 (0) | 2013.09.04 |
jns와 jnz 소스분석 - 문예진 (1) | 2013.09.04 |
Group 파일 분석 [문남경] (0) | 2013.09.04 |
ASSEMBLY - jmp 명령어, group 파일 분석 - 전영기 (0) | 2013.09.04 |
group 파일 분석 (0) | 2013.09.03 |
UNIX 숙제 -/etc/group -0903 -임기준 (0) | 2013.09.03 |