Answer to Question #242841 in Assembler for Xyz

Question #242841

Write a program that take an Alphabet C (C can be uppercase or lowercase) as input and print all the character between C (input character) to uppercase Z if C is uppercase or to lowercase z if C is lowercase. NB: Implement the above problem inside Separate Procedure.


1
Expert's answer
2021-09-27T03:17:05-0400
TITLE   print all the character between char and Z/z
INCLUDE Irvine32.inc

.data
msgEnter    BYTE "Enter char: ",0
msgErr    BYTE "Err char",0

.code
main PROC
   mov edx, OFFSET msgEnter        ; address of string msgEnter
   call writeString                ; writes a string "Enter char: "
   call ReadChar
   call WriteChar
    call    crlf                ; new string    

; Check char
   cmp al,'A'
   jl _err        ; char < A
   cmp al,'z'
   jg _err        ; char > z
   cmp al,'Z'
   jg nextCheck
   jmp funcDisplay

nextCheck:
    cmp al, 'a'    
    jl  _err    ; Z < char < a

funcDisplay:
; al = char
;************************************
   call DisplayAlphabet
   jmp _quit
 
 _err:
   mov edx, OFFSET msgErr        ; address of string msgEnter
   call writeString                ; writes a string "Err char"

 _quit:
     call    crlf                ; new string    
    call    crlf                ; new string
    exit
main ENDP

DisplayAlphabet PROC
   mov dl, al
   mov ecx, 26    ; number char's in Alphabet

; check upp/lower
   cmp al,'Z'
   jle upcase    
   sub dl,'a'
   jmp next

upcase:
   sub dl,'A'   
next:
   sub cl, dl
 
begin:
    call writeChar
    inc al
    loop begin


    ret
DisplayAlphabet 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