What this program should do
I am taking two numbers as input from the user and want to check if these two numbers are not equal to zero. Then the program should just add them, but if the first variable is greater than the second, then it should be subtracted from the second.
In the other case it shouldn't perform any operation and prompt the user the possible error.
Here is my code adding both two numbers.
The errors I get are:
- When I enter two zeros, it just executes all instructions step by step.
- And subtraction is not performing.
DOSSEG
.MODEL SMALL
.STACK 100H
.DATA
VAR1 DB ?
VAR2 DB ?
MSG1 DB 'ADDITION IS : $'
MSG2 DB 'ADDITION IS NOT POSSIBLE : $'
MSG3 DB 'SUBTRACTION IS : $'
MSG4 DB 'SUBTRACTION IS NOT POSSIBLE : $'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS ,AX
MOV AH ,1
INT 21H
MOV VAR1 ,AL
MOV AH, 1
INT 21H
MOV VAR2 ,AL
CMP VAR2,0
JNE J1
JE J3
J1:
CMP VAR1,0
JNE J2
JE J4
J2:
MOV DX ,OFFSET MSG1
MOV AH,9
INT 21H
MOV DL,VAR2
ADD DL,VAR1
SUB DL,48
MOV AH,2
INT 21H
MOV DL,VAR1
JMP L5
JE L8
L5:
MOV DX ,OFFSET MSG3
MOV AH,9
INT 21H
MOV BL,VAR2
SUB DL,BL
ADD DL,48
MOV AH,2
INT 21H
JMP J9
L8:
MOV DX ,OFFSET MSG4
MOV AH,9
INT 21H
JMP J9
J3:
MOV DX ,OFFSET MSG2
MOV AH,9
INT 21H
JMP J9
J4:
MOV DX ,OFFSET MSG2
MOV AH,9
INT 21H
JMP J9
J9:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN