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.
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
Comments
Leave a comment