This program suppose to take number of rows and print a triangle of stars like this:
How many row for the triangle? = 12
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*********************
***********************
Please help with no much modification if possible !!
;Assembly Version
.model small
.stack
.data
msg1 db 'How many rows for the traingle? : $'
msg2 db 'Error: too many cols !! $'
nrow db ?
mult db 2
var dw 80
ncol dw ?
.code
.startup
mov ax,@data
mov ds,ax
xor si,si
xor bx,bx
;prompt the user to enter number of rows
mov dx,offset msg1
mov ah,09h
int 21h
;read number of rows
mov ah,01h
int 21h
sub al,30h
mov nrow,al
cbw
mov cx,ax
;calculate number of coulms
mul mult
sub ax,1
mov ncol,ax
;check validity of number of cols
cmp ax,var
jge error
;print in new line
mov dl,10d
mov ah,02h
int 21h
mov dl,13d
mov ah,02h
int 21h
mov al,nrow
outerLoop:
add bl,1
xor dl,dl
sub nrow,bl
jmp condition1
condition1:
call printspace
add dl,1
cmp dl,nrow
jle condition1
xor dl,dl
mov al,bl
mul mult
add dl,1
jmp condition2
condition2:
call printstare
add dl,1
cmp dl,al
jl condition2
;print in new line
mov dl,10d
mov ah,02h
int 21h
mov dl,13d
mov ah,02h
int 21h
loop outerLoop
jmp finish
error:
mov dx,offset msg2
mov ah,09h
int 21h
jmp finish
finish :
mov ah,4ch
int 21h
printspace:
push ax
push bx
push cx
push dx
mov dl,' '
mov ah,02h
int 21h
pop dx
pop cx
pop bx
pop ax
ret
printstare:
push ax
push bx
push cx
push dx
mov dl,'*'
mov ah,02h
int 21h
pop dx
pop cx
pop bx
pop ax
ret
END
Alerwiali 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.