0% found this document useful (0 votes)
29 views

Installer - Exe/download Pn2421440.zip

The document provides instructions for a lab assignment to write an assembly language program to sort 10 numbers using bubble sort in signed ascending order, from -50 to 55, and provides links to download necessary software like NASM and DOSBox to write and test the code. Students are instructed to share their code and screen output over Skype or Adobe Connect with the teacher during the lab.

Uploaded by

Muhammad Awais
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Installer - Exe/download Pn2421440.zip

The document provides instructions for a lab assignment to write an assembly language program to sort 10 numbers using bubble sort in signed ascending order, from -50 to 55, and provides links to download necessary software like NASM and DOSBox to write and test the code. Students are instructed to share their code and screen output over Skype or Adobe Connect with the teacher during the lab.

Uploaded by

Muhammad Awais
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab 5

Write Assembly language program to sort the following numbers, using bubble sort, in signed ascending
order:

-15, -30, -12, -50, 10, 20, 55, 40, 7, 0

That is, at the end of your program, the numbers must be in the following order:

-50, -30, -15, -12, 0, 7, 10, -20, 40,55

Mechanism to Conduct Lab:

Students and teacher communicate through Skype/Adobe Connect. Students will write code using
Notepad or Programmer’s Notepad and will share code and screen output.

Nasm: https://vulms.vu.edu.pk/Courses/CS401/Downloads/AssmSoft.zip

DosBOX: http://sourceforge.net/projects/dosbox/files/dosbox/0.74-2/DOSBox0.74-2-win32-
installer.exe/download

Programmers Notepad: https://github.com/simonsteele/pn/releases/download/v2.4.2/portable-


pn2421440.zip

Solution:

program to sort the numbers, using bubble sort, in signed descending order

[org 0x0100]

jmp start

data: dw -15, -30, -12, -50, 10, 20, 55, 40, 7, 0

swap: db 0

start: mov bx, 0 ; initialize array index to zero

mov byte [swap], 0 ; rest swap flag to no swaps

loop1: mov ax, [data+bx] ; load number in ax

cmp ax, [data+bx+2] ; compare with next number

jle noswap ; no swap if already in order

mov dx, [data+bx+2] ; load second element in dx

mov [data+bx+2], ax ; store first number in second

mov [data+bx], dx ; store second number in first


mov byte [swap], 1 ; flag that a swap has been done

noswap:

add bx, 2 ; advance bx to next index

cmp bx, 18 ; are we at last index

jne loop1 ; if not compare next two

cmp byte [swap], 1 ; check if a swap has been done

je start ; if yes make another pass

mov ax, 0x4c00 ; terminate program

int 0x21

You might also like