[su_box title=”Generic Diamond” style=”bubbles” box_color=”#1d318d”]
org 100h
.data
A db 0
B db 0
C db 0ah
D db 0dh
countstr db 0
str db 1
space db 0
str1 db ‘Enter odd Diamond $’
str2 db ‘*’
spaces db ‘ ‘
.code
;Enter odd Diamond No
lea dx,str1
mov ah,9
int 21h
;Taking Number
mov ah,1
int 21h
;Saving in ‘a’
mov a,al
sub a,48
mov cl,a
;For Next Line
mov dl,c
mov ah,2
int 21h
mov dl,d
mov ah,2
int 21h
;For space find Line
mov al,a
mov bl,2
mov ah,0
div bl
mov space,al
mov countstr,al
inc countstr
inc countstr
inc countstr
inc countstr
inc space
mov cl,a
;loop of fuul diamond
full:
mov b,cl
;dec space
mov ch,0
mov cl,space
cmp space,0
Je cxd
;for printing spaces
spa:
mov dl,spaces
mov ah,2
int 21h
loop spa
;stars
mov cl,str
;star
star:
mov dl,str2
mov ah,2
int 21h
loop star
;For Next Line
mov dl,c
mov ah,2
int 21h
mov dl,d
mov ah,2
int 21h
;dec spacx
dec space
inc str
inc str
mov cl,b
loop full
cxd:
mov al,a
mov str,al
dec str
dec str
mov cl,b
inc space
inc space
full2:
mov b,cl
mov cl,space
;for printing spaces
spa1:
mov dl,spaces
mov ah,2
int 21h
loop spa1
cmp str,0
JLE exit1
mov cl,str
;Star
star1:
mov dl,str2
mov ah,2
int 21h
loop star1
;For Next Line
mov dl,c
mov ah,2
int 21h
mov dl,d
mov ah,2
int 21h
;
;
dec str
dec str
inc space
mov cl,b
loop full2
exit1:
ret
[/su_box]
Table of Contents