- 题目:输入华氏温度,显示其对应的摄氏温度
- 要求:程序从键盘接收用户键入的华氏温度值,根据转换公式运算后,显示对应的摄氏温度值。在用户输入和显示转换结果之前都要有相应的提示信息。
- 当用户输入华氏温度值后,进行运算,然后显示计算结果。
转换公式:C = (5/9) * (F-32)
;其中F是华氏温度,C是摄氏温度
1 ; Example assembly language program -- adds two numbers
2 ; Author: karllen
3 ; Date: revised 5/2014
4
5 .386
6 .MODEL FLAT
7
8 ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
9
10 INCLUDE io.h ; header file for input/output
11
12 cr EQU 0dh ; carriage return character
13 Lf EQU 0ah ; line feed
14
15 .STACK 4096 ; reserve 4096-byte stack
16
17 .DATA
18 promot1 BYTE "Please enter a number as a Fahrenheit ",cr,Lf,0
19 value BYTE 11 DUP(?)
20 answer BYTE "The Temperature is"
21 va BYTE 11 DUP(?)
22 BYTE cr,Lf,0
23
24 ;C = (5/9) * (F-32)
25
26 .CODE
27 _start:
28 output promot1
29 input value,11
30 atod value
31 sub eax,32 ;eax = F-32
32 mov ebx,eax ;ebx = F-32
33
34 mov eax,1 ;eax = eax/edx 5/9
35
36 mul ebx ;eax*ebx
37
38 dtoa va,eax
39 output answer
40
41 INVOKE ExitProcess, 0 ; exit with return code 0
42
43 PUBLIC _start ; make entry point public
44
45 END ; end of source code
汇编语言-华氏温度转换为摄氏温度,布布扣,bubuko.com
时间: 2024-10-18 05:26:08