Print Generic Triangle – Assembly Language Code

0

Assembly Language Code to Print Hollow Triangle in Generic.

[su_box title=”Generic Triangle” style=”bubbles” box_color=”#1d318d”]

; You may customize this and other start-up templates;
; The location of this template is c:\emu8086\inc\0_com_template.txt

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 dl,countstr
cmp str,dl
JE exit
mov cl,str
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:
exit:

ret

[/su_box]

Table of Contents

OutPut Screen:

Generic Triangle Code

Find More Assembly Codes Here!

Leave A Reply