Solved programming problem

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

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

    mov l,1

   

con1:    

    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++

     ; dec starcount

      jmp cond2

exit:

   

     mov ah,9

     lea dx,nl

     int 21h

     

     inc l         ;l++

     dec starcount ; starcount--

     jmp con1

   

   

exitouter:

endp

end main

Output

*****

****

***

**

*

Join the discussion

Add your comment