Answer to Question #284830 in Assembler for Ahmed Ali

Question #284830

1) Write a program in assembly language to the handle following cases.


The program takes a character input.

Enter any character From A-Z :


  • If the user enters an uppercase alphabet simply show the message “This is upper case letter”
  • If the user enters a lowercase alphabet, then simply show the message “This is lower case letter”
  • If the user enters any other character its shows the wrong input.
1
Expert's answer
2022-01-04T16:21:47-0500
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS