s

8086 assembly language program to print an inverted pyramid with tree character and space edit button Edit

author
Khanii Khan @gmail.com | calendar 12 February 2021 | 3154

Here is the 8086 assembly language program to print an inverted pyramid with tree character and space

Problem Statement

Display Below Sequence

Solution

.model tiny
.code
org 100h

main proc
    mov cx,5
    loop1:
        push cx
        printnthline:
            mov dl,05   ; to display tree pattern which is the fifth element in the character table
            mov ah,02   ; dos function 02h to print a character
            int 21h     ; dos interrupt 21h
            mov dl,' '  ; space after character
            mov ah,02   ; dos function 02h to print a character
            int 21h     ; dos interrupt 21h
        loop printnthline
        mov dl,0Ah  ; carrage return character
        mov ah,02
        int 21h
        mov dl,0Dh  ; line feed character
        mov ah,02
        int 21h
        pop cx      ; pop the value of cx
    loop loop1:     ; loop instructin decrements the value of cx and compares if the value is zero, if the value is not zero it jumps to label else next line    
    ret
end main
endp