Reputation: 11
The output should be
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
5x10 OR 10x5
The requirement is that there should be LOOP, INC AND/OR DEC only.
This is what I did, the result is infinite loop:
.model small
.stack
.code
start:
mov ah, 02h
mov cx, 10
l1:
mov bx, 12 ; loop pababa n bente
l2:
mov dl,78h
int 21h
loop l2
dec bx
mov dl, 0dh ; carriage return
int 21h
mov dl, 0ah ;line feed
int 21h
mov cx, bx
loop l1
mov ah, 4ch
int 21h
end start
Upvotes: 0
Views: 1535
Reputation: 9899
You should clearly separate the outer loop from the inner loop.
I've written your code using BX as the outer loop control variable and using CX as the inner loop control variable.
mov ah, 02h ;CONST for both loops
---- Start of outer loop ----
mov bx, 5 ;Do 5 lines like in your example
l1:
---- Start of inner loop ----
mov cx, 10 ;Put 10 characters on each line
mov dl, 'X'
l2:
int 21h
loop l2
---- End of inner loop ----
mov dl, 0dh ;CR
int 21h
mov dl, 0ah ;LF
int 21h
dec bx
jnz l1
---- End of outer loop ----
Upvotes: 1
Reputation: 984
Your problem is that you are making bx 12 (mov bx, 12) at the beginning of loop 1, then decrementing it by 1 after loop 2, then assigning its value to cx at the end of loop 1. Bx will only ever be 12 or 11, and cx will only ever be 11.
I think your fix is to move the (mov cx, bx) line to before the l1: loop begins, not after it begins as you have it now.
Upvotes: 0