예제 4장 |
.386 .MODEL FLAT add ax,2 ; rounding factor for division mov bx,5 ; divisor cwd ; prepare for division add ax,32 ; C*9/5 + 32 output Answer ; output label and result PUBLIC _smart ; make entry point public END |
|
4장 4_4 1번문제 |
;The formula for converting a Fahrenheit to a Celsius temperature is ;C = (5/9) * (F - 32);Write a complete 80x86 assembly language program to prompt for a ;Fahrenheit temperature and display the corresponding Celsius temperature. .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 Fahrenheit " BYTE "temperature to the Celsius scale",cr,Lf,Lf BYTE "Enter Fahrenheit temperature: ",0 Value BYTE 10 DUP (?) Answer BYTE CR,LF,"The temperature is" Temperature BYTE 6 DUP (?) BYTE " Celsius",cr,Lf,0 .CODE _smart: Prompt: output Prompt1 ; prompt for Celsius temperature input Value,10 ; read ASCII characters atoi Value ; convert to integer sub ax, 32 ; ax = ax-32 imul ax, 5 ; ax = ax*5 add ax, 4 ; rounding factor for division mov cx, 9 ; divisor cwd ; prepare for division idiv cx ; C = (5/9) * (F - 32) itoa Temperature, ax ; convert to ASCII characters output Answer ; output label and result INVOKE ExitProcess, 0 ; exit with return code 0 PUBLIC _smart ; make entry point public END |
|
'코스웨어 > 13년 스마트컨트롤러' 카테고리의 다른 글
어셈블리 과제 - 조유진 (0) | 2013.09.02 |
---|---|
어셈블리 복습 (실수는 어떻게 계산 되는가?) (1) | 2013.09.02 |
어셈블리어 과제_ 진종영 (0) | 2013.09.02 |
2013.09.02_사용권한설정 및 shadow 필드_깨알설명_김성엽 (0) | 2013.09.02 |
어셈블리 숙제 0902 임기준 (0) | 2013.09.02 |
어셈블리 과제2 - 손초롱 (0) | 2013.09.02 |
20130902과제 - 전영기 (0) | 2013.09.02 |
130902 - 월요일 정리 문예진 (0) | 2013.09.02 |