0% found this document useful (0 votes)
144 views5 pages

Write A Program in Assembly Language That Display The Following Output Using Loop: 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1

This assembly language program displays a pyramid pattern of decreasing numbers using loops. It prints the numbers from 123454321 down to 1 in decreasing steps, with extra spaces added between the numbers at each line. Variables are used to store the digit values and output is printed using DOS interrupts. Loops decrement and print the values across each line until reaching 1 in the center at the bottom.

Uploaded by

Homi Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
144 views5 pages

Write A Program in Assembly Language That Display The Following Output Using Loop: 1 2 3 4 5 4 3 2 1 1 2 3 4 4 3 2 1 1 2 3 3 2 1 1 2 2 1 1 1

This assembly language program displays a pyramid pattern of decreasing numbers using loops. It prints the numbers from 123454321 down to 1 in decreasing steps, with extra spaces added between the numbers at each line. Variables are used to store the digit values and output is printed using DOS interrupts. Loops decrement and print the values across each line until reaching 1 in the center at the bottom.

Uploaded by

Homi Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Q2(b) Write a program in assembly language that display the following output using loop:

123454321

1234 4321

123 321

12 21

1 1

.model small
.stack 100h
.data

var db 49
var2 db 52
var3 db 53
four db 53
one db 48

ws db 32

tpfour db 52
tpone db 49

.code
main proc
mov Ax,@data
mov Ds,Ax
mov ah, 02h

mov cx, 5

l1:

mov bx, cx

mov cx, 9
mov ah, 02h
mov dl, var

l2:

int 21h
inc dl

cmp dl, four


je exit
loop l2

exit:

mov ah, 02h


mov dl, var3
int 21h

mov dl, var2

l3:
cmp dl, one
je exit2

int 21h
dec dl

loop l3

exit2:

mov ah, 02h


mov dl, 0ah
int 21h
mov dl, 0dh
int 21h
cmp var3, 53
je jump

dec four
dec var2

jump:
mov var3, 32

mov cx, bx

loop l1

mov ah,4ch
int 21h

main endp
end main

You might also like