一个汇编程序,出了点问题,请教一下各位高手!谢谢!
DATAS SEGMENTSTRING1 DB 'Please input four hex numbers:',0AH,'$'
ER DB 0AH,0DH,'$'
STRING2 DB 'The hex numbers converted to binary numbers are:',0AH,'$'
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;**********************输入数字提示语*******************************
LEA DX,STRING1
MOV AH,09H
INT 21H
MOV CL,4
MOV DX,CX
MOV BX,0
INPUT:
MOV AL,0
MOV AH,1
INT 21H
CMP AL,'9'
JBE NEXT2 ;键入值小于等于‘9’(‘0’~‘9’)则减30H
CMP AL,'a'
JB NEXT1 ;键入值小于‘a’(‘A’~‘F’)则减37H
SUB AL,20H ;键入值在‘a’~‘f’则先减20H,再减37H
NEXT1:
SUB AL,7
NEXT2:
SUB AL,30H
SHL BX,CL
ADD BX,AX
DEC DX
JNZ INPUT
;****************************在屏幕上打印换行符*****************************************
LEA DX,ER
MOV AH,09H
INT 21H
LEA DX,STRING2
MOV AH,09H
INT 21H
SUB BX,4352;调整,减去1000100000000 = 4352,不知道为什么会出现这种情况
MOV CX,16
AGAIN:
SHL BX,1
JC NEXT3
MOV DL,'0'
MOV AH,6
INT 21H
JMP NEXT4
NEXT3:
MOV DL,'1'
MOV AH,6
INT 21H
NEXT4:
LOOP AGAIN
MOV AH,4CH
INT 21H
CODES ENDS
END START
为什么SUB BX,4352;调整,减去1000100000000 = 4352, 这里要这样调整,还有就是NEXT2:
SUB AL,30H
SHL BX,CL
ADD BX,AX
DEC DX
JNZ INPUT
这里怎么知道他会结束?