上传用户:hzsgec
上传日期:2022-06-23
资源大小:2374k
文件大小:2k
- ;Example assembly language program -- adds two numbers
- ; Author: Unknown
- ; Date: 2009-1-1
- .386
- .MODEL FLAT
- ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
- INCLUDE io.h ; header file for input/output
- cr EQU 0dh ; carriage return character
- Lf EQU 0ah ; line feed
- .STACK 4096 ; reserve 4096-byte stack
- .DATA ; reserve storage for data
- number1 DWORD ?
- number2 DWORD ?
- prompt1 BYTE cr,Lf,"程序目的:计算两个整数之和",cr,Lf,cr,Lf,
- "请输入一个整数:", 0
- prompt2 BYTE cr,Lf,"请输入另一个整数:", 0
- string BYTE 40 DUP (?),0
- label1 BYTE cr, Lf, "这两个整数相加之和为:"
- sum BYTE 11 DUP (?)
- BYTE cr, Lf, 0
- .CODE ; start of main program code
- _start:
- output prompt1 ; prompt for first number
- input string, 40 ; read ASCII characters
- atod string ; convert to integer
- mov number1, eax ; store in memory
- output prompt2 ; repeat for second number
- input string, 40
- atod string
- mov number2, eax
- mov eax, number1 ; first number to EAX
- add eax, number2 ; add second number
- dtoa sum, eax ; convert to ASCII characters
- output label1 ; output label and sum
- INVOKE ExitProcess, 0 ; exit with return code 0
- PUBLIC _start ; make entry point public
- END ; end of source code