• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 6 pages
Class notes

Assembly Language Bubble Sort Program – Sort 10 Numbers in Ascending Order (OPCODE/8086)

Document preview thumbnail
Preview 2 out of 6 pages

This is a complete solved Assembly Language long question on Bubble Sort. Write an Assembly Language program to sort a list of ten numbers in ascending order using Bubble Sort. The notes provide the required program and explanation in an easy-to-understand format. It is useful for students preparing for Assembly Language exams, practicals, assignments, and viva. Topics Covered: * Bubble Sort Algorithm * Sorting 10 Numbers * Ascending Order * Assembly Language Program * OPCODE / 8086 Assembly * Comparisons and Swapping * Loops and Registers * Exam-oriented solution Suitable for: BSCS, Computer Science, IT and related students.

Content preview

Q1: Write assembly program to sort a list of ten numbers in
ascending order using bubble sort.

.model small
.stack 100h
.data
; Array of 10 numbers to sort
numbers db 10, 2, 8, 4, 5, 9, 1, 6, 7, 3
n db 10 ; number of elements in array

.code
main proc
mov ax, @data ; initialize data segment
mov ds, ax

; Outer loop: passes
mov cx, n ; CX = 10
dec cx ; CX = 9 passes needed
outer_loop:
mov si, 0 ; SI = index of first element

; Inner loop: compare adjacent elements
mov dx, cx ; DX = number of comparisons in this pass
inner_loop:
mov al, numbers[si] ; AL = current element
mov bl, numbers[si+1] ; BL = next element
cmp al, bl
jbe no_swap ; if AL <= BL, no swap

; Swap AL and BL
mov numbers[si], bl
mov numbers[si+1], al
no_swap:
inc si ; move to next element
dec dx
jnz inner_loop ; repeat inner loop

dec cx ; next pass
jnz outer_loop ; repeat outer loop

; End program (DOS interrupt)
mov ah, 4ch
int 21h

, main endp
end main


1. Concept: Bubble Sort

Bubble sort algorithm:

 Compare each pair of adjacent elements.
 Swap them if they are in the wrong order.
 Repeat steps 1–2 for the entire list until no swaps are needed.

For a list of 10 numbers, we perform 9 passes, because after each pass the
largest number “bubbles” to its correct position.

 arr → numbers ki list
 outer loop → total passes
 inner loop → adjacent comparison
 cmp → compare numbers
 jbe → agar already correct ho to swap nahi
 End pe array ascending order mein sort ho jata hai



Q2: How would you print capital ‘A’ with blue foreground
and red background with no blinking property? write its
assembly code?
Step 1: Understanding the color attributes

In text mode (like 80x25), colors are specified in one byte:

Lower 4 bits → Foreground color

Upper 3 bits → Background color

1 bit → Blink (if set, character blinks)

Color codes:

Foreground:

0 = Black

1 = Blue

Document information

Uploaded on
August 18, 2026
Number of pages
6
Written in
2026/2027
Type
Class notes
Professor(s)
Sir ali
Contains
All classes
$3.79

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
43
Last sold
-




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions