1) Write a program in assembly language to the handle following cases.
The program takes a character input.
Enter any character From A-Z :
INCLUDE Irvine32.inc
.data
msgEnter BYTE "Enter char: ",0
msgWrong BYTE 10,"The wrong input",0
msgUpper BYTE 10,"This is upper case letter",0
msgLower BYTE 10,"This is lower case letter",0
.code
main PROC
mov edx, OFFSET msgEnter ; address of string msgEnter
call writeString ; writes a string "Enter char: "
call ReadChar
call writeChar
; Check char
cmp al,'A'
jl _wrong ; char < A
cmp al,'z'
jg _wrong ; char > z
cmp al,'Z'
jg nextCheck ; Z > char < a
jmp displayMsg
nextCheck:
cmp al, 'a'
jl _wrong ; Z < char < a
displayMsg:
; al = char
cmp al, 'a'
jge displayLow
;************************************
mov edx, OFFSET msgUpper ; address of string
call writeString ; writes a string
jmp _quit
displayLow:
mov edx, OFFSET msgLower ; address of string
call writeString ; writes a string
jmp _quit
_wrong:
mov edx, OFFSET msgWrong ; address of string msgEnter
call writeString ; writes a string "The wr "
_quit:
call crlf ; new string
call crlf ; new string
exit
main ENDP
END main
Comments
Leave a comment