Bubble Sorting program in assembly language on emulator 8086.


1- Declare an Array

2- Set all elements to 0

3- Take 10 inputs in the array

4- Start a loop of 10 itteration

5- Compare index 0 to index 1

6- Swap elements if index 1 is greater

7- Iterate the Loop 10 times

8-Print the Sorted Array

Bubble Sort program in assembly language

[su_box title=”Bubble Sort” style=”bubbles” box_color=”#1d318d”]

org 100h


str db 10,13,”Enter Values: $”
str1 db 0dh,0ah,”Bubble Sorted: $”
array db 10dup(0)


mov ah,9
lea dx,str
int 21h

mov cx,10
mov bx,offset array
mov ah,1

int 21h
mov [bx],al
inc bx
Loop inputs

mov cx,10
dec cx

mov bx,cx
mov si,0

mov al,array[si]
mov dl,array[si+1]
cmp al,dl

jc noswap

mov array[si],dl
mov array[si+1],al

inc si
dec bx
jnz nextcomp

loop nextscan

mov ah,9
lea dx,str1
int 21h

mov cx,10
mov bx,offset array

; this loop to display elements on the screen
mov ah,2
mov dl,[bx]
int 21h
inc bx
loop print



Output Screen:

Bubble Sort Output