Question
In Assembly Language Programming I already have most of the code done I just need to add a function that displays and classifies the entered
In Assembly Language Programming
I already have most of the code done I just need to add a function that displays and classifies the entered character in number, letter or symbol. Example if the user enters A then the programs displays: A - letter, 3 - number, & - symbol.
The code is the following:
.MODEL SMALL
.STACK
.DATA
STRING db "Enter a character: ",13,10,13,10,'$' CHARACTER db ?
.CODE MAIN PROC MOV AX, @DATA MOV DS, AX ; your code goes here
call SHOW_STRING
call READ_CHARACTER call WRITE_CHARACTER
call CLEAR_KEYBOARD_BUFFER
MOV AX, 4C00h INT 21h
MAIN ENDP
;***********************************************************************************
SHOW_STRING PROC mov dx, offset STRING ; write all characters mov ah, 9 ; in the standard output int 21h ; DX has the offset of the first character RET ; the last character must be '$' SHOW_STRING ENDP
;***********************************************************************************
WRITE_CHARACTER PROC mov ah, 2h ; write a character to standard output mov dl, CHARACTER ; DL has the character int 21H RET WRITE_CHARACTER ENDP
;***********************************************************************************
READ_CHARACTER PROC mov ah, 8h ; read a character without echo from standard input int 21h ; AL stores the character read mov CHARACTER, al RET READ_CHARACTER ENDP
;*********************************************************************************** CLEAR_KEYBOARD_BUFFER PROC mov ah, 0bh ; check standard input status int 21h ; AL = 0 if input buffer is empty
cmp al, 0h ; jz CLEARED ; are there no more characters in the standard input NEXT: call READ_CHARACTER mov ah, 0bh ; check standard input status int 21h ; AL = 0 if input buffer is empty cmp al, 0h ; jnz NEXT ; are there more characters in the standard input CLEARED: RET CLEAR_KEYBOARD_BUFFER ENDP end MAIN
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started