Question: This code needs to be fix INCLUDE asmlib.inc . data ; Data segment to store prompts and messages prompt BYTE Enter a character: ,

This code needs to be fix
INCLUDE asmlib.inc
.data ; Data segment to store prompts and messages
prompt BYTE "Enter a character: ",0
outpA BYTE "is a digit", 0
outpB BYTE "is a vowel", 0
outpC BYTE "is arithmetic", 0
outpD BYTE "Not a vowel, digit, or arithmetic character. Must be something else.", 0
.code ; Code segment where logic is implemented
main PROC
; Display prompt and get a single character input
mov edx, OFFSET prompt ; Load prompt message
call WriteString ; Print prompt
call ReadChar ; Read single character into AL
; Check if character is a digit
call isDigit
cmp eax, 1 ; Check if eax ==1(is digit)
je DigitFound ; If yes, jump to DigitFound
; Check if character is a vowel
call isVowel
cmp eax, 1 ; Check if eax ==1(is vowel)
je VowelFound ; If yes, jump to VowelFound
; Check if character is an arithmetic operator
call isArithmetic
cmp eax, 1 ; Check if eax ==1(is arithmetic)
je ArithmeticFound ; If yes, jump to ArithmeticFound
; Character is something else
mov edx, OFFSET outpD
call WriteString
jmp EndProgram ; End program
DigitFound:
mov edx, OFFSET outpA
call WriteString
jmp EndProgram
VowelFound:
mov edx, OFFSET outpB
call WriteString
jmp EndProgram
ArithmeticFound:
mov edx, OFFSET outpC
call WriteString
jmp EndProgram
EndProgram:
exit ; Exit the program
main ENDP
; Checks if character in AL is a digit (0-9)
isDigit PROC
mov eax, 0 ; Initialize eax to 0(assume not a digit)
cmp al,'0' ; Check if AL >='0'
jl NotDigit ; If less, jump to NotDigit
cmp al,'9' ; Check if AL <='9'
jg NotDigit ; If greater, jump to NotDigit
mov eax, 1 ; Set eax to 1(is a digit)
NotDigit:
ret
isDigit ENDP
; Checks if character in AL is a vowel (a, e, i, o, u, A, E, I, O, U)
isVowel PROC
mov eax, 0 ; Initialize eax to 0(assume not a vowel)
cmp al,'A'
je VowelFound
cmp al,'E'
je VowelFound
cmp al,'I'
je VowelFound
cmp al,'O'
je VowelFound
cmp al,'U'
je VowelFound
cmp al,'a'
je VowelFound
cmp al,'e'
je VowelFound
cmp al,'i'
je VowelFound
cmp al,'o'
je VowelFound
cmp al,'u'
je VowelFound
jmp NotVowel
VowelFound:
mov eax, 1 ; Set eax to 1(is a vowel)
NotVowel:
ret
isVowel ENDP
; Checks if character in AL is an arithmetic operator (+,-,*,/)
isArithmetic PROC
mov eax, 0 ; Initialize eax to 0(assume not an arithmetic operator)
cmp al,'+'
je ArithmeticFound
cmp al,'-'
je ArithmeticFound
cmp al,'*'
je ArithmeticFound
cmp al,'/'
je ArithmeticFound
jmp NotArithmetic
ArithmeticFound:
mov eax, 1 ; Set eax to 1(is an arithmetic operator)
NotArithmetic:
ret
isArithmetic ENDP
END main
Please fix the problem

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!