-
写一个完整的8086汇编语言程序,求解表达式-3x-y+1的值,结果显示在屏幕上。
;计算-3x-y+1
;作者:KUN.A.A
;date:2022/03/25
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h
cr EQU 0dh ; carriage return character
LF EQU 0ah ; linefeed character
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
Prompt1 BYTE "This program will evaluat the expression",cr,Lf,Lf
BYTE " -3x-y+1 ",cr,Lf,Lf
BYTE "for your choice of integer values.",cr,Lf,Lf
BYTE "Enter value for x: ",0
Prompt2 BYTE "Enter value for y: ",0
Value BYTE 16 DUP (?)
Answer BYTE cr,Lf,"The result is "
Result BYTE 6 DUP (?)
BYTE cr,Lf,0
.CODE ; start of main program code
_start:
output Prompt1 ;输出语句
input Value,16 ;输入到value
atoi Value ;转为整型
mov dx,ax ;x
imul dx,3 ;3x
output Prompt2 ;输出语句
input Value,16 ;输入到value
atoi Value ;转为整型
add dx,ax ;3x+y
neg dx ;-3x-y
inc dx ;-3x-y+1
itoa result,dx ;结果放入result
output Answer ;输出语句
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code
2.
- 写一个完整的8086汇编语言程序,满足以下要求:
- 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据存储的值20。
- 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据的值从键盘输入。
- 将上述两个值自加1后显示在屏幕上。
.Data
Number1 word 20 ;number1=20 “20”
Number2 word ?
Res1 byte 10 dup (?)
Result byte 6 dup (?)
.code
Inc number1
Itoa result, number1
Output result
; 数据自增1
; 作者:KUN.A.A
; date:2022/3/25
.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 word 20 ; number1=20"20"
Number2 word ?
Res1 byte 10 dup(?),0
Result byte 6 dup(?),0
Prompt1 BYTE "This program will inc 1 the expression",cr,Lf,Lf
BYTE "first Number1 is: ",0
Prompt2 BYTE cr,Lf,Lf,"input second Number2: ",0
prompt3 BYTE cr,Lf,Lf,"inc+1hou: ",0
.CODE
_start:
output Prompt1 ;输出语句1
itoa result,number1 ;转为ASCII,放入20
output result ;输出20
inc number1 ;+1
itoa result,number1 ;转为ASCII,放入21
output prompt3 ;输出语句3
output result ;输出21
output Prompt2 ;输出语句2
input res1,10 ;输入res1
atoi res1 ;转为整型
mov number2,ax ;res在AX,数据赋值给number2
inc number2 ;+1
itoa result,number2 ;转为ASCII
output prompt3 ;输出语句3
output result ;输出结果
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code