org 100h
.model small
.data
star db 0
starcount db 5
l db 0
line db 5
nl db 0ah,0dh,"$"
d db ?
.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
mov d, '0'
cond2:
mov dl,starcount ;i<=n
cmp star,dl
jle print
jmp exit
print:
add d,1 ;print the position
mov dl,d
mov ah,2
int 21h
inc star ;i++
jmp cond2
exit:
mov ah,9
lea dx,nl
int 21h
inc l
dec starcount
jmp con1
exitouter:
endp
end main
Output
12345
1234
123
12
1
Add your comment