Microprocessor and Microcontroller Lab 2 | Read Now

Microprocessor and Microcontroller Lab 2

2] Design and develop an assembly program to sort a given set of ‘n’ 16- bit numbers in ascending order. Adopt bubble sort algorithm to sort given elements.


2] Program Code(las2.asm)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
.model small
.stack 10
.data
org 01h
a db 03h,01h,04h,02h
count dw 04
.code
mov ax,@data
mov ds,ax
mov bx,count
dec bx
outloop:mov cx,bx
mov si,0
inloop: mov al,a[si]
inc si
cmp al,a[si]
jl down
xchg al,a[si]
mov a[si-1],al
down: loop inloop
dec bx
jnz outloop
mov ah,4ch
int 21h
end
.model small .stack 10 .data org 01h a db 03h,01h,04h,02h count dw 04 .code mov ax,@data mov ds,ax mov bx,count dec bx outloop:mov cx,bx mov si,0 inloop: mov al,a[si] inc si cmp al,a[si] jl down xchg al,a[si] mov a[si-1],al down: loop inloop dec bx jnz outloop mov ah,4ch int 21h end
.model small
.stack 10
.data
	org 01h
	a db 03h,01h,04h,02h
	count dw 04

.code
mov ax,@data
mov ds,ax
mov bx,count
dec bx

outloop:mov cx,bx
	mov si,0

inloop:	mov al,a[si]
	inc si
	cmp al,a[si]
	jl down
	xchg al,a[si]
	mov a[si-1],al

down:	loop inloop
	dec bx
	jnz outloop

mov ah,4ch
int 21h
end

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp Icon Join For Job Alerts