汇编语言当AX=008FH的时候用CMP AL,0和JNL NEXT语句为什么不进行跳转?但是用小于这个数字就可以
这是一个求根号的程序利用1+3+5+7+9=25=5^2这个原理,当求144以上时出错CRLFMACROMOVDL,0DHMOVAH,02HINT21HMOVDL,0AH...
这是一个求根号的程序 利用1+3+5+7+9=25=5^2这个原理,当求144以上时出错
CRLF MACRO
MOV DL,0DH
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
ENDM
DATA SEGMENT
DATA1 DB 'Input the number!','$'
DATA2 DB 'The answer is:','$'
MID DB -1
NUM DB 20
DB ?
DB 20 DUP(?)
TEN DB 10
RESULT DB 20 DUP(?)
DATA ENDS
STACK SEGMENT
STA DW 256 DUP(?)
TOP EQU LENGTH STA
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
LEA DX,DATA1 ;显示输入数字
MOV AH,9
INT 21H
LEA DX,NUM ;输入数字
MOV AH,10
INT 21H
CRLF
LEA BX,NUM
MOV SI,0
MOV CX,0
ADD BX,02H
BCD: SUB DS:[BX+SI],byte ptr 30H ;ASCII变非压缩BCD码
INC SI
INC CX
CMP DS:[BX+SI],byte ptr 0DH
JNE BCD
MOV SI,0
MOV AX,0
HEX: MUL TEN
ADD AL,DS:[BX+SI]
INC SI
LOOP HEX
LEA BX,MID
MOV CX,0FFH
NEXT: ADD DS:[BX],BYTE PTR 02H ;开方运算,结果送CX
SUB AL,DS:[BX]
INC CX
CMP AL,0
JGE NEXT ;!!!就是这里!!!
LEA DX,DATA2 ;显示结果
MOV AH,9
INT 21H
MOV AL,CL
MOV AH,0
LEA BX,RESULT
MOV SI,0
ASCII: DIV TEN ;数字变ASCII码
ADD AH,30H
MOV DS:[BX+SI],AH
INC SI
MOV AH,0
CMP AL,0
JG ASCII
DISPLAY:MOV DL,DS:[BX+SI]
MOV AH,2
INT 21H
DEC SI
CMP SI,0
JGE DISPLAY
MOV AX,4C00H
INT 21H
CODE ENDS
END START 展开
CRLF MACRO
MOV DL,0DH
MOV AH,02H
INT 21H
MOV DL,0AH
MOV AH,02H
INT 21H
ENDM
DATA SEGMENT
DATA1 DB 'Input the number!','$'
DATA2 DB 'The answer is:','$'
MID DB -1
NUM DB 20
DB ?
DB 20 DUP(?)
TEN DB 10
RESULT DB 20 DUP(?)
DATA ENDS
STACK SEGMENT
STA DW 256 DUP(?)
TOP EQU LENGTH STA
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
LEA DX,DATA1 ;显示输入数字
MOV AH,9
INT 21H
LEA DX,NUM ;输入数字
MOV AH,10
INT 21H
CRLF
LEA BX,NUM
MOV SI,0
MOV CX,0
ADD BX,02H
BCD: SUB DS:[BX+SI],byte ptr 30H ;ASCII变非压缩BCD码
INC SI
INC CX
CMP DS:[BX+SI],byte ptr 0DH
JNE BCD
MOV SI,0
MOV AX,0
HEX: MUL TEN
ADD AL,DS:[BX+SI]
INC SI
LOOP HEX
LEA BX,MID
MOV CX,0FFH
NEXT: ADD DS:[BX],BYTE PTR 02H ;开方运算,结果送CX
SUB AL,DS:[BX]
INC CX
CMP AL,0
JGE NEXT ;!!!就是这里!!!
LEA DX,DATA2 ;显示结果
MOV AH,9
INT 21H
MOV AL,CL
MOV AH,0
LEA BX,RESULT
MOV SI,0
ASCII: DIV TEN ;数字变ASCII码
ADD AH,30H
MOV DS:[BX+SI],AH
INC SI
MOV AH,0
CMP AL,0
JG ASCII
DISPLAY:MOV DL,DS:[BX+SI]
MOV AH,2
INT 21H
DEC SI
CMP SI,0
JGE DISPLAY
MOV AX,4C00H
INT 21H
CODE ENDS
END START 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询