新手求大神指点,为什么程序运行和调试结果不一样。。
将一组有符号数“38H,4AH,0C5H,83H,9CH,0B4H,7FH,0C4H,05H,0F5H”中的负数求和,并在屏幕上以十进制的形式显示结果。
MASM6.0编写,运行环境是32位XP虚拟机。程序运行的时候显示错误结果“-0”,但是调试时候却能显示正确结果“-206”。。求问一下到底是哪里出错了。。
DATAS SEGMENT
DECIMALST DB 15 DUP(0)
NEGETIV DB 15 DUP(0)
NUMBERS DB 38H,4AH,0C5H,83H,9CH,0B4H,7FH,0C4H,05H,0F5H
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV AX,0
MOV BX,0
CALL JUDGE
CALL ADDITION
CALL OUTPUT
MOV AH,4CH
INT 21H
JUDGE PROC NEAR
LEA SI,NEGETIV
LEA DI,NUMBERS
MOV CX,0AH
MOV DL,0A0H
CHECKS:
MOV BL,[DI]
INC DI
CMP BX,DX
JG NEGETIVE
BACKCHECK:
LOOP CHECKS
RET
NEGETIVE:
MOV [SI],BL
INC SI
JMP BACKCHECK
JUDGE ENDP
ADDITION PROC NEAR
LEA SI,NEGETIV
ADDS:
MOV BL,[SI]
INC SI
NEG BL
CMP BL,0
JZ EXITA
ADD AX,BX
JMP ADDS
EXITA:
RET
ADDITION ENDP
OUTPUT PROC NEAR
MOV DX,0
MOV CX,10D
LEA DI,DECIMALST
DIVID:
DIV CX
MOV [DI],DL
INC DI
INC BH
MOV DX,0
CMP AX,0
JZ PRINTFIRST
JMP DIVID
PRINTFIRST:
MOV AH,2
MOV DL,'-'
INT 21H
PRINT:
MOV AH,2
DEC DI
MOV DL,[DI]
ADD DL,30H
INT 21H
DEC BH
JZ EXITOP
JMP PRINT
EXITOP:
RET
OUTPUT ENDP
CODES ENDS
END START