I am trying to display:
A123*B123*C123*
in DOSBox using loop but instead I'm getting:
A1*2*3*B*1*2*3*C*1*2*3*D
Here is my current code:
.model small
.stack
.data
.code
main proc
mov cx,3
mov ah, 2
mov dl, 'A'
Letter: int 21h
push cx
push dx
mov cx, 3
mov ah, 2
mov dl, '1'
Number: int 21h
push cx
push dx
mov ah, 2
mov cx, 1
mov dl, '*'
Aste: int 21h
Loop Aste
pop dx
pop cx
add dl,1
Loop Number
pop dx
pop cx
add dl, 1
Loop Letter
int 21h
mov ah,4ch
int 21h
main endp
end main
I tried switching the way I would run the loops but whenever I put the loop "aste" at the end it will print '*' nonstop.
Why would you create a loop if all you need to output is a single character? It also made you write these annoying
pushes andpops.Solve the task from the inside out
The task requires the use of two loops. We will call these 'nested loops' as the 'inner loop' will be embedded in the 'outer loop'.
Begin with the inner loop that simply prints
123*Athat we retrieve from an available register like BLNow we enclose this by the outer loop
ABandCInsert it in your skeleton program and enjoy the view!