• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 6 páginas
Notas de lectura

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

Document preview thumbnail
Vista previa 2 fuera de 6 páginas

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.

Vista previa del contenido

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

Información del documento

Subido en
18 de agosto de 2026
Número de páginas
6
Escrito en
2026/2027
Tipo
Notas de lectura
Profesor(es)
Sir ali
Contiene
Todas las clases
$3.79

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
0
Seguidores
0
Artículos
43
Última venta
-




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes