Answer to Question #285107 in Assembler for Ahmed Ali

Question #285107

1) Write a program in assembly language using emu8086 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.


The program must be compatible with emu8086.


1
Expert's answer
2022-01-06T08:51:56-0500
DATA SEGMENT
msgEnter    db "Enter char: $"
msgWrong    db 10,"The wrong input$"
msgUpper    db 10,"This is upper case letter$"
msgLower    db 10,"This is lower case letter$"
DATA ENDS

CODE SEGMENT
START:
    MOV AX,DATA
    MOV DS,AX    
    MOV ES,AX

    mov dx, offset msgEnter
    mov ah, 9
    int 21h    
    
; wait for any key press:
    mov ah, 0
    int 16h    
    mov     ah, 0eh
    int     10h  
    
; 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 dx, OFFSET msgUpper        ; address of string  
       mov ah, 9
    int 21h              ; writes a string
   jmp _quit

displayLow:
   mov dx, OFFSET msgLower        ; address of string  
    mov ah, 9
    int 21h      ; writes a string
   jmp _quit

 _wrong:
   mov dx, OFFSET msgWrong        ; address of string msgEnter
       mov ah, 9
    int 21h                  ; writes a string "The wr   "

 _quit:    
   MOV AH,1            ; Waiting for a key press
    INT 16H    

EXIT_PROG:            ; Program is terminated
     MOV AH,4CH
     INT 21H

CODE ENDS
END START

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