【微机原理】—汇编题
编程实现Z=5X+3Y+10,设已知变量和结果均放在数据段.
方法一
DATA SEGMENT
X DW 5
Y DW 6
Z DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV CL,2
SHL AX,CL
ADD AX,X
MOV BX,Y
SHL BX,1
ADD AX,BX
ADD AX,Y
ADD AX,10
MOV Z,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
方法二
DATA SEGMENT
X DW 5
Y DW 6
Z DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AX,X
MOV CX,5
MUL CX
MOV CX,AX
MOV AX,Y
MOV BX,3
MUL BX
ADD AX,CX
ADD AX,10
MOV Z,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START