Last active
February 25, 2021 13:39
Tonmoy Problem for Question - Assembly - 0-10 even or odd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.DATA | |
PROMPT_1 DB \'Enter the number from 0 to 10 : $\' | |
PROMPT_2 DB 0DH,0AH,\'The number is : $\' | |
.CODE | |
MAIN PROC | |
MOV AX, @DATA ; initialize DS | |
MOV DS, AX | |
LEA DX, PROMPT_1 ; load and print PROMPT_1 | |
MOV AH, 9 | |
INT 21H | |
MOV AH, 1 ; read a digit | |
INT 21H | |
MOV BL, AL ; save the digit in BL | |
LEA DX, PROMPT_2 ; load and print PROMPT_2 | |
MOV AH, 9 | |
INT 21H | |
TEST BL, 01H ; check the digit for even or odd | |
JNE @ODD ; jump to label @ODD if the number is odd | |
MOV AH, 2 ; print the letter \'E\' | |
MOV DL, \"E\" | |
INT 21H | |
JMP @EXIT ; jump to the label @EXIT | |
@ODD: ; jump label | |
MOV AH, 2 ; print the letter \'O\' | |
MOV DL, \"O\" | |
INT 21H | |
@EXIT: ; jump label | |
MOV AH, 4CH ; return control to DOS | |
INT 21H | |
MAIN ENDP | |
END MAIN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment