Monday, November 3, 2008

Displaying asterisk triangles

Will it took me time to get myself to blogging again , this is one my own projects that I program using assembly in my school , but this is just one pattern I'll blog the rest after this


Source Code:

jmp start
mess1 db 10,13, "Enter a value (n) [0-9 only]: $"
mess2 db 10,13, "Do you want to continue (y/n): $"
mess3 db 10,13, "There is nothing to display $"
space db " $"
lincar db 10,13, "$"
value db 0
counter db 0

start:
xor ax,ax
xor bx,bx
xor cx,cx

mov ax,3
int 10h

lea dx,mess1
mov ah,9
int 21h

mov ah,1
int 21h
sub al,30h

cmp al,0
jl start
cmp al,9
jg start

mov value,al
cmp al,0
je zero

lea dx,lincar
mov ah,9
int 21h

mov ah,0
mov al,value

mov cx,ax
mov counter,1
mov bh,counter
mov bl,1
jmp display
start_bridge:
jmp start
display:
cmp bh,bl
jg next

mov dl,'*'
mov ah,2
int 21h

lea dx,space
mov ah,9
int 21h

inc bh
jmp display
next:
inc bl
mov bh,counter

lea dx,lincar
mov ah,9
int 21h

loop display
jmp continue
zero:
lea dx, mess3
mov ah,9
int 21h
jmp continue
continue:
xor dx,dx

lea dx,mess2
mov ah,9
int 21h

mov ah,1
int 21h

cmp al,'y'
je start_bridge
cmp al,'n'
je quit

jmp continue
quit:
int 20h

No comments: