TITLE
;--------------------------------------------------------------
.MODEL SMALL
.STACK 64
.DATA
MSGA DB 13, 10, "Input expression: ","$$$" ;asks the user input expression ie. 5+2
MSGADD DB 13, 10, "The sum is: ","$"
MSGSUB DB 13, 10, "The difference is :","$"
MSGMUL DB 13, 10, "The product is: " ,"$"
MSGDIV DB 13, 10, "The quotient is: ","$"
NUM1 db ?
NUM2 db ?
OP db ?
.CODE
MAIN PROC NEAR
MOV AX,@DATA
MOV DS,AX
LEA DX,MSGA
MOV AH,09H ;reads the user input
INT 21H
MOV AH,01H ; scan NUM1
INT 21H ;interruption
SUB AH,32
MOV NUM1,AH
MOV AH,01H ; also reads from the keyboard
INT 21H ; scan NUM2
SUB AH,32
MOV NUM2,AH
;MOV NUM2,AL
MOV AH,01H ; also reads from the keyboard
INT 21H ; scan OP
SUB AH,32
MOV OP,AH
CMP AX,'+'
je @ADD
CMP AX,'-'
;je @SUB
CMP AX,'*'
;je @MUL
CMP AX,'/'
;je @DIV
@ADD:
ADD AH,NUM1 ;add first number
ADD AH,NUM2
MOV NUM1,AH
ADD NUM1,32
LEA DX,MSGADD
MOV AH,09h
INT 21h
MOV DL,NUM1
MOV AH,02h
INT 21h
@DIV:
XOR AX,AX ;EXAMPLE ON THE BOARD
MOV AX,83H
MOV BL,2H
DIV BL
MOV AH,4CH ;for exiting purpose
INT 21H
@endif:
MAIN ENDP
;---------------------------------------------------------------
END MAIN
为什么我的代码不起作用?结果它没有给出数字,而是通常给出一个 pi 字符。