I need to write a code in 8086 emulator where a user gives an input from 0 to 9. If the value is below 3, 'Good morning!' is printed. If the value is greater or equal to 4 and less than 6 (just 4 and 5, basically), 'Good afternoon!' is printed. If the value is greater or equal to 8, 'Good night!' is printed. For the values 3, 6 and 7, the system does nothing.
However, in my case, I am getting an output for these three values as well. What are the issues with my code?
.MODEL SMALL
.STACK 100H
.DATA
STRING1 DB "Enter number:$"
STRING2 DB "Good morning!$"
STRING3 DB "Good afternoon!$"
STRING4 DB "Good night!$"
.CODE
MAIN PROC
MOV AX , @DATA
MOV DS , AX
LEA DX , STRING1
MOV AH , 9
INT 21h
MOV AH , 1
INT 21h
SUB AL , 30h
CMP AL , 3
JL good_morning
CMP AL , 6
JL next_check
CMP AL , 8
JGE good_night
good_morning:
LEA DX , STRING2
MOV AH , 9
INT 21h
JMP exit_label
next_check:
CMP AL , 4
JGE good_afternoon
good_afternoon:
LEA DX , STRING3
MOV AH , 9
INT 21h
JMP exit_label
good_night:
LEA DX , STRING4
MOV AH , 9
INT 21h
JMP exit_label
exit_label:
MOV AX , 4C00H
INT 21h
MAIN ENDP
END MAIN