;以下面形式定义一个长整数,其所占用字节数由N得到,比如128位(16字节)
;的数57 46 35 24 13 DE 89 67 45 23 BC 9A 78 56 34 12H定义成:
;NUM DB 12H,34H,56H,78H,9AH,0BCH,23H,45H
; DB 67H,89H,0DEH,13H,24H,35H,46H,57H
;N DB $-NUM
;试编写一个程序,实现对N字节的NUM的值求补(类似NEG的操作),并把求反后的值
;仍保存在NUM中。求补即是取反后加1
DATA SEGMENT
NUM DB 12H,34H,56H,78H,9AH,0BCH,23H,45H
DB 67H,89H,0DEH,13H,24H,35H,46H,57H
N DB $-NUM
DATA ENDS
STACK SEGMENT PARA STACK
DW 128 DUP(?)
TOP LABEL WORD
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,SS:STACK,DS:DATA
MAIN PROC FAR
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
LEA SP,TOP
LEA SI,NUM
MOV CL,N
XOR CH,CH
STC ;将进位标志CF=1,用于第一次最低位的加1
L1: MOV AL,[SI]
NOT AL
ADC AL,0 ;ADC操作会改变CF,以后取反后是否会加1根据实际数据不同
MOV [SI],AL
INC SI
LOOP L1
MOV AH,4CH
INT 21H
CODE ENDS
MAIN ENDP
END START