Solved programming problem

Basic Star Print in Assembly(Nested Loop -2).

Source code

org 100h

.model small

.data

    star db 0

    starcount db 5

    l db 0

    line db 5

    nl db 0ah,0dh,"$"

 

 

.code

mov ax,@data

mov ds,ax

main proc

 

    mov star,1  ; i=0    for 2nd loop

    mov l,1

                        ; for 1st loop

cond1:  

    mov dl,line ; i<=n

    cmp l,dl

    jle printstar

    jmp exitouter

printstar:

  mov star,1

cond2:  

    mov dl,starcount ;i<=n

    cmp star,dl

    jle print

    jmp exit

 

print:

      mov ah,2   ;print

      mov dl,'*'

      int 21h    

   

      inc star ;i++

      jmp cond2

exit:

 

     mov ah,9

     lea dx,nl

     int 21h

     

     inc l   ; outer i++

     jmp cond1

   

   

exitouter:

endp

end main

Output

*****

*****

*****

*****

*****

Join the discussion

Add your comment