利用16位汇编指令实现32位的加减乘操作,并且说明在执行过程中各个标志位的变化以及变化的原因。
DATAS SEGMENT
A dw -100; FFFFFFFF9C
B dw 77 ; 4D
V dw 11 ; B
D dw 9 ; 9
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
; ADD
MOV AX,A
CWD
MOV CX,AX
MOV DX,BX
MOV AX,B
CWD
ADD AX,CX
ADC DX,BX
MOV AH,4CH
INT 21H
CODES ENDS
END START
DATAS SEGMENT
A dw -100; FFFFFFFF9C
B dw 255 ; FF
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
; SUB
MOV AX,A
CWD
MOV CX,AX
MOV BX,DX
MOV AX,B
CWD
SUB AX,CX
SBB DX,BX
MOV AH,4CH
INT 21H
CODES ENDS
END START
DATAS SEGMENT
XH DW 0001H ;x1
XL DW 1234H ;x2
YH DW 0002H ;y1
YL DW 1234H ;y2
TEMP DW 4 DUP (?)
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
; MUL
MOV AX,XL
MOV DX,YL
MUL DX
MOV [TEMP],DX
MOV [TEMP+2],DX
MOV AX,XH
MOV DX,YL
MUL DX
ADD [TEMP+2],AX
ADC [TEMP+4],DX
MOV AX,XL
MOV DX,YH
MUL DX
ADD [TEMP+2],AX
ADC [TEMP+4],DX
ADC [TEMP+6],0
MOV AX,XH
MOV DX,YH
MUL DX
ADD [TEMP+4],AX
ADC [TEMP+6],DX
MOV AH,4CH
INT 21H
CODES ENDS
END START