Hello, I'm a begginer at this asm code stuff and I've had to write a couple of simple and basic begginers programs. Well the one that I have to do now has to have an output that looks like this:

*
**
***
****
*****
and it must be a nested loop meaning a loop inside of a loop.

In this program we have to use a counter, line feed, carriage return, and nested loop. My teacher said that there should be two counters. I'm trying but every time my output looks like:

*
*
*
*
*
*
*
or it looks like

*
*
*
*
*
*
*
*
*
*
Can someone please tell me what the heck I'm doing wrong????!!!! PLEASE ASAP :confused: :sad:

This is my code:

org 100h

mov bl,0
L1: mov al,'*'
mov ah,0eh ;prints to screen
int 10h

mov al,10 ;line feed
mov ah,0eh
int 10h

inc bl ;counter
cmp bl,5

jne L1


mov al,13 ;carriage return
mov ah,0eh
int 10h

mov bl,0
inc bl
cmp bl,5

jne L1

you need two counters -- the first counter counts the number of lines to be printed, the second counter counts the number of stars that are printed on the current line. Your code is putting a CR/LF after every star. This should happen only after the stars have been printed on the current line. You need two loops and two counters to accomplish that.

I see what you are saying but now I'm just getting my self confused. I tried something different. I put two print out screens. I don't think there is suppose to be two those, and I got something that looked like this:

*
**
**
**
**
**
**
**
**
**

It's like my counters are not added up right, like it's stuck. Do yall have any suggestions for me please???
Hey if yall see someone that responded others can respond to, the more I hear it maybe you could translates what someone else is already said, but I could better understand you. :-)

my code:

org 100h

L2: mov al,13 ;cr
mov ah,0eh
int 10h

mov al,'*'
mov ah,0eh ;prints to screen
int 10h

inc bl ;counter
cmp bl,5


jne L1

L1: mov al,10 ;line feed
mov ah,0eh
int 10h


mov al,'*'
mov ah,0eh ;prints to screen
int 10h


inc bl ;counter
cmp bl,5

jne L2

I think it should be something like this -- I didn't assemble or test it.

;
mov  bx,1 ; row counter
loop_start::
xor cx,cx ; column counter
l1:
 mov al,'*'
mov ah,0eh ;prints to screen
int 10h 
inc cx
cmp cx,bx ; have we printed enough stars ?
jne l1  ; no, then do it again
:print CR/.LF
;
; save our two loop counters
push bx
push cx
mov al,10 ;line feed
mov ah,0eh
int 10h 
mov al,13 ; CR
mov ah,0eh
int 10h
; restore our two loop counters
pop cx
pop bx
; process row counter
inc bx
cmp bx,5
jne loop_start

Well yes it worked and I'm happy to see that it loops like it should on the paper, but now I have to look at it some more and see how I could substitue some codes for something else, b/c we never used the xor. I don't even know what that does. What exactly is "XOR"? Then I have to make it loop twice so I can get the same print out:

*
**
***
****
*****
*
**
***
****
*****

So I'll try and maybe you can help me if I can't get it. :-)

Oh I see now. Well I doctored it up and I really understand it now. I looked at every step and saw how it really worked and what I was doing wrong. I even understand the jumps a little bit better now to thanks to your help. I took out the push's and pop's because they really didn't not have any effect on the code. I really really want to thank you a lot for helping me out and allow me to understand this program better. I hope that if I have any other program problems you will be around to help me out. :-) Thanks

This is my what the code now looks like:

main: mov bl,1 ;this command counts the rows
L2: mov cl,0 ;this command counts the column

L1: mov al,'*' ;puts a star into register al
mov ah,0eh ;prints to screen
int 10h

inc cl ;helps with the number of stars
cmp cl,bl ;that will be printed

jne L1 ;jumps to L1 if register cl and
;register bl are not equal

mov al,10 ;line feed
mov ah,0eh
int 10h

mov al,13 ;carriage return
mov ah,0eh
int 10h


inc bl ;keeps up with counting the rows
cmp bl,6 ;and tells how many rows are left
;to be print

jne L2 ;Jumps to L2 when register bl is "not"
;equal to 6

jmp main ;jumps back to the very first step
;of the code to allow it to repeat
;indefinitely when all the rows has
;been accounted for

I took out the push's and pop's because they really didn't not have any effect on the code.

I got into the habbit of pushing all registers that I want to save before calling any interrups or functions because (1) general purpose registers ax, bx, cx and dx are subject to change without notice and (2) you don't know if the function or interrupt called will change them. Better safe then sorry.

the code looks pretty good....

however on windows/dos you should print CR/LF (which is 0x0d 0x0a )

in the code you have them backwards

hmm...okay. I'm finished with my code I was just speaking to you. I got a 100 on that assignment with the stars that you helped me out with. Thanks

This question has already been answered. Start a new discussion instead.