mov cx, 5 ; counter
Mov dl, 65 ; A
t1:
mov ah, 2h
int 21h
add dl, 32 ; 97 - 65 - convert to LC
mov ah, 2h
int 21h
sub dl,31 ;remove the 32 added, but increment
push dx ;save DX on stack
mov dl, 32 ;space character
mov ah, 2h
int 21h
pop DX ;return DX from stack
loop t1
[Amended in the light of Michael's comment - Add dl,1 became sub dl,31
]
(I've omitted your initialisation and termination which should be fine)
Your issues are:
t1..t2 : load DL
with 'A'
and output it; then increment
t2..loop t2 instruction: load DL
with 'a'
and output it; then increment
- do this 5 (contents of CX
) times. Note you are loading DL
with 'a'
each time
- AND that CX
will be decremented each loop, so the loop terminates when CX
BECOMES 0
loop t2: Next, loop back to t1 and repeat until CX
BECOMES 0.
So, at the loop t1
, CX
is already 0, and is thus decremented and the program loops back to t1, so A
is output until CX
once again becomes 0, 65534 loops later.