我有个汇编程序调试通过不了,请大家帮帮忙啊!看看错在哪儿了
程序功能:从键盘上输入两个四位的16进制数,并在屏幕上显示这两个数的和。DATASEGMENTSTRBUF1DB'Pleaseinputthefirstdata:,$'F...
程序功能:从键盘上输入两个四位的16进制数,并在屏幕上显示这两个数的和。
DATA SEGMENT
STRBUF1 DB 'Please input the first data:,$'
FIRST DB 4 DUP(?)
STRBUF2 DB 'Please input the second data:,$'
SECOND DB 4 DUP(?)
STRBUF3 DB 'Display the sum:,$'
SUM DB 5 DUP(?)
STRBUF4 DB 'Please input 1 and exit!'
DATA ENDS
STACK SEGMENT
DB 100 DUP(0)
TOP DB ?
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET TOP
LEA DX,STRBUF1
MOV AH,9
INT 21H
LEA DX,FIRST
MOV AH,0AH
INT 21H
LEA DX,STRBUF2
MOV AH,9
INT 21H
LEA DX,SECOND
MOV AH,0AH
INT 21H
MOV DI,OFFSET FIRST
CALL READH
MOV DI,OFFSET SECOND
CALL READH
POP AX
POP BX
ADD AX,BX
JNC AA2
MOV BL,1
ADD BL,30H
MOV DI,OFFSET SUM
MOV [DI],BL
INC DI
JMP AA3
AA2:MOV DI,OFFSET SUM
AA3:MOV DX, AX
CALL CONHA
MOV [DI+3],BL
MOV [DI+2],BH
MOV AL,DH
CALL CONHA
MOV [DI+1],BL
MOV [DI],BH
DISPLAY:LEA DX,STRBUF3
MOV AH,09H
INT 21H
LEA DX,SUM
MOV AH,09H
INT 21H
LEA DX,STRBUF4
MOV AH,09H
INT 21H
AA1: MOV AH,01H
INT 21H
CMP AL,31H
JNZ AA1
MOV AH,4CH
INT 21H
READH PROC NEAR
MOV CX,4
MOV SI,CX
MOV BX,0
AA0: MOV AL,[DI]
CALL CONV
SHL BX,CL
ADD BL,AL
INC DI
DEC SI
JNZ AA0
PUSH BX
RET
READH ENDP
CONV PROC
CMP AL,'9'
JBE CONV2
CMP AL,'a'
JB CONV1
SUB AL,20H
CONV1: SUB AL,7
CONV2: SUB AL,30H
RET
CONV ENDP
CONHA PROC
MOV AH,AL
AND AL,OFH
CMP AL,0AH
JB ASC1
ADD AL,07
ASC1: ADD AL,30H
MOV BL,AL
MOV CL,4
SHR AH,CL
CMP AH,0AH
JB ASC2
ADD AH,07
ASC2: ADD AH,30H
MOV BH,AH
RET
CONHA ENDP
CODE ENDS
END START
多谢,第100行的指令的确写错了
现在可以通过编译了,但是还是不能实现题目所要实现的功能,不知为何??? 展开
DATA SEGMENT
STRBUF1 DB 'Please input the first data:,$'
FIRST DB 4 DUP(?)
STRBUF2 DB 'Please input the second data:,$'
SECOND DB 4 DUP(?)
STRBUF3 DB 'Display the sum:,$'
SUM DB 5 DUP(?)
STRBUF4 DB 'Please input 1 and exit!'
DATA ENDS
STACK SEGMENT
DB 100 DUP(0)
TOP DB ?
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET TOP
LEA DX,STRBUF1
MOV AH,9
INT 21H
LEA DX,FIRST
MOV AH,0AH
INT 21H
LEA DX,STRBUF2
MOV AH,9
INT 21H
LEA DX,SECOND
MOV AH,0AH
INT 21H
MOV DI,OFFSET FIRST
CALL READH
MOV DI,OFFSET SECOND
CALL READH
POP AX
POP BX
ADD AX,BX
JNC AA2
MOV BL,1
ADD BL,30H
MOV DI,OFFSET SUM
MOV [DI],BL
INC DI
JMP AA3
AA2:MOV DI,OFFSET SUM
AA3:MOV DX, AX
CALL CONHA
MOV [DI+3],BL
MOV [DI+2],BH
MOV AL,DH
CALL CONHA
MOV [DI+1],BL
MOV [DI],BH
DISPLAY:LEA DX,STRBUF3
MOV AH,09H
INT 21H
LEA DX,SUM
MOV AH,09H
INT 21H
LEA DX,STRBUF4
MOV AH,09H
INT 21H
AA1: MOV AH,01H
INT 21H
CMP AL,31H
JNZ AA1
MOV AH,4CH
INT 21H
READH PROC NEAR
MOV CX,4
MOV SI,CX
MOV BX,0
AA0: MOV AL,[DI]
CALL CONV
SHL BX,CL
ADD BL,AL
INC DI
DEC SI
JNZ AA0
PUSH BX
RET
READH ENDP
CONV PROC
CMP AL,'9'
JBE CONV2
CMP AL,'a'
JB CONV1
SUB AL,20H
CONV1: SUB AL,7
CONV2: SUB AL,30H
RET
CONV ENDP
CONHA PROC
MOV AH,AL
AND AL,OFH
CMP AL,0AH
JB ASC1
ADD AL,07
ASC1: ADD AL,30H
MOV BL,AL
MOV CL,4
SHR AH,CL
CMP AH,0AH
JB ASC2
ADD AH,07
ASC2: ADD AH,30H
MOV BH,AH
RET
CONHA ENDP
CODE ENDS
END START
多谢,第100行的指令的确写错了
现在可以通过编译了,但是还是不能实现题目所要实现的功能,不知为何??? 展开
展开全部
1、第100行的指令可能是你输入时有误,AND AL,OFH 中的0FH(是零FH)误写的OFH(欧FH)。
2、在下面两条指令
MOV AH,4CH
INT 21H
前加两条指令
MOV AH,1
INT 21H
等待按键,保证结果在屏幕上停留一段时间,以便看清结果。
补充答案:终于调试通过了。
DATA SEGMENT
STRBUF1 DB 'Please input the first data:$'
FIRST DB 5,?,5 DUP(?)
STRBUF2 DB 'Please input the second data:$'
SECOND DB 5,?,5 DUP(?)
NUMBER DW ?,?
STRBUF3 DB 'Display the sum:$'
SUM DB 6 DUP(?),'$'
STRBUF4 DB 'Please any key to exit!$'
DATA ENDS
STACK SEGMENT
DB 100 DUP(0)
TOP DB ?
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET TOP
LEA DX,STRBUF1
MOV AH,9
INT 21H
LEA DX,FIRST
MOV AH,0AH
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
LEA DX,STRBUF2
MOV AH,9
INT 21H
LEA DX,SECOND
MOV AH,0AH
INT 21H
MOV AH,2
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H
LEA BP,NUMBER
MOV DI,OFFSET FIRST+2
CALL READH
MOV DI,OFFSET SECOND+2
CALL READH
MOV AX ,NUMBER
MOV BX ,NUMBER+2
ADD AX,BX
JNC AA2
MOV BL,1
ADD BL,30H
MOV DI,OFFSET SUM
MOV [DI],BL
INC DI
JMP AA3
AA2:MOV DI,OFFSET SUM
AA3:MOV DX, AX
CALL CONHA
MOV [DI+3],BL
MOV [DI+2],BH
MOV AL,DH
CALL CONHA
MOV [DI+1],BL
MOV [DI],BH
MOV BYTE PTR [DI+4],'$'
DISPLAY:LEA DX,STRBUF3
MOV AH,09H
INT 21H
LEA DX,SUM
MOV AH,09H
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
LEA DX,STRBUF4
MOV AH,09H
INT 21H
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
READH PROC NEAR
MOV CX,4
MOV SI,CX
MOV BX,0
AA0: MOV AL,[DI]
CALL CONV
SHL BX,CL
ADD BL,AL
INC DI
DEC SI
JNZ AA0
MOV DS:[BP],BX
ADD BP,2
RET
READH ENDP
CONV PROC NEAR
CMP AL,'9'
JBE CONV2
CMP AL,'a'
JB CONV1
SUB AL,20H
CONV1: SUB AL,7
CONV2: SUB AL,30H
RET
CONV ENDP
CONHA PROC NEAR
MOV AH,AL
AND AL,0FH
CMP AL,0AH
JB ASC1
ADD AL,07
ASC1: ADD AL,30H
MOV BL,AL
MOV CL,4
SHR AH,CL
CMP AH,0AH
JB ASC2
ADD AH,07
ASC2: ADD AH,30H
MOV BH,AH
RET
CONHA ENDP
CODE ENDS
END START
2、在下面两条指令
MOV AH,4CH
INT 21H
前加两条指令
MOV AH,1
INT 21H
等待按键,保证结果在屏幕上停留一段时间,以便看清结果。
补充答案:终于调试通过了。
DATA SEGMENT
STRBUF1 DB 'Please input the first data:$'
FIRST DB 5,?,5 DUP(?)
STRBUF2 DB 'Please input the second data:$'
SECOND DB 5,?,5 DUP(?)
NUMBER DW ?,?
STRBUF3 DB 'Display the sum:$'
SUM DB 6 DUP(?),'$'
STRBUF4 DB 'Please any key to exit!$'
DATA ENDS
STACK SEGMENT
DB 100 DUP(0)
TOP DB ?
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,OFFSET TOP
LEA DX,STRBUF1
MOV AH,9
INT 21H
LEA DX,FIRST
MOV AH,0AH
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
LEA DX,STRBUF2
MOV AH,9
INT 21H
LEA DX,SECOND
MOV AH,0AH
INT 21H
MOV AH,2
MOV DL,0DH
INT 21H
MOV DL,0AH
INT 21H
LEA BP,NUMBER
MOV DI,OFFSET FIRST+2
CALL READH
MOV DI,OFFSET SECOND+2
CALL READH
MOV AX ,NUMBER
MOV BX ,NUMBER+2
ADD AX,BX
JNC AA2
MOV BL,1
ADD BL,30H
MOV DI,OFFSET SUM
MOV [DI],BL
INC DI
JMP AA3
AA2:MOV DI,OFFSET SUM
AA3:MOV DX, AX
CALL CONHA
MOV [DI+3],BL
MOV [DI+2],BH
MOV AL,DH
CALL CONHA
MOV [DI+1],BL
MOV [DI],BH
MOV BYTE PTR [DI+4],'$'
DISPLAY:LEA DX,STRBUF3
MOV AH,09H
INT 21H
LEA DX,SUM
MOV AH,09H
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
MOV AH,2
MOV DL,0AH
INT 21H
LEA DX,STRBUF4
MOV AH,09H
INT 21H
MOV AH,1
INT 21H
MOV AX,4C00H
INT 21H
READH PROC NEAR
MOV CX,4
MOV SI,CX
MOV BX,0
AA0: MOV AL,[DI]
CALL CONV
SHL BX,CL
ADD BL,AL
INC DI
DEC SI
JNZ AA0
MOV DS:[BP],BX
ADD BP,2
RET
READH ENDP
CONV PROC NEAR
CMP AL,'9'
JBE CONV2
CMP AL,'a'
JB CONV1
SUB AL,20H
CONV1: SUB AL,7
CONV2: SUB AL,30H
RET
CONV ENDP
CONHA PROC NEAR
MOV AH,AL
AND AL,0FH
CMP AL,0AH
JB ASC1
ADD AL,07
ASC1: ADD AL,30H
MOV BL,AL
MOV CL,4
SHR AH,CL
CMP AH,0AH
JB ASC2
ADD AH,07
ASC2: ADD AH,30H
MOV BH,AH
RET
CONHA ENDP
CODE ENDS
END START
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询