The program must display letters from a
to z
(alternate uppercase and lowercase horizontally) using looping.
Sample Output :
AaBb . . . . . . . . . . . . YyZz
This is the code I've used so far but it only outputs the uppercase letters. Please help me how to combine those lower case letters :(
Thank you :)
.model small
.code
.stack 100
org 100h
start :
mov ah, 02h
mov cl, 41h
skip :
mov dl, cl
Int 21h
inc cl
cmp cl, 5Ah
jnz skip
Int 27h
end start
If you want them interspersed, the ASCII character set has an offset of 20h
between the uppercase and lowercase letters:
You can see from that table that moving from A
to a
requires adding 20h
(to go from 41h
to 61h
) and this is the same for all other letters as well.
So, instead of simply adding one at the end of the loop, you must first:
20h
.1fh
(i.e., subtract 20h
then add one).In other words, change:
mov dl, cl
int 21h
inc cl
into something like:
mov dl, cl ; load dl with character and print.
int 21h
add cl, 20h ; move to lowercase variant and print.
mov dl, cl
int 21h
sub cl, 1fh ; move back to next uppercase variant.
The code can be made shorter if you know that the interrupt won't clobber the dl
register you're using (and the excellent Ralf Brown interrupt list seems to indicate this is so, stating that only al
is changed):
mov dl, cl ; load dl with character and print.
int 21h
add dl, 20h ; move dl to lowercase variant and print.
int 21h
inc cl ; move cl to next uppercase variant.