This project is maintained by MahediKamal
Note: Input should be given between 0 to 9.
Sample Input 1:
4
Sample Output 1:
1
1 2
1 2 3
1 2 3 4
Sample Input 2:
6
Sample Output 2:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
.model small
.stack 100h
.data
i db 31h ; ASCII value of '1' is 31h: i=1
j db 31h ; ASCII value of '0' is 30h: i=1
.code
main proc
mov ax,@data
mov ds,ax
; ......input..........
mov ah,1
int 21h
mov bl,al; saving our input in bl
; handeling the corner case of 0
cmp bl,30h ; checking if given input id 0. ASCII value of
; 0 is 30h
je exit
while_1: ; this loop will iterate from i=1 to i=input
; going to new line
mov ah,2
mov dl,0dh
int 21h
mov ah,2
mov dl,0ah
int 21h
mov j,31h ; setting j with 1. as ASCII value of 1 is 31h
while_2: ; this loop will iterate from j=1 to j=i
mov ah,2
mov dl,j
int 21h
inc j ; j++ or j = j+1
mov bh,i ; putting the value of i in bh to
; compare with j
cmp j,bh ; we can't compare 2 variable directly,
; so we put the value of i in bh
jle while_2
inc i
cmp i,bl
jle while_1
exit:
main endp
end main