Computer Architecture and Assembly Language Programming - CS401 Spring 2009 Assignment 02 Solution
Computer Architecture and Assembly Language Programming - CS401 Spring 2009 Assignment 02 Solution
net
CS401- Computer Architecture and Assembly Language
Programming
Assignment # 2
Spring 2009
Total Marks: 20
Solution:
Program code:
; program to sort the numbers, using bubble sort, in signed descending order
[org 0x0100]
jmp start
data: dw -10, -30, -25, 50, 15, 20, 35, 40, 45, 0
swap: db 0
Page 1 of 3
http://lms.vusr.net
www.VUSR.net
Screen-shots:
As the program starts execution, the unsorted data is loaded in memory (M1
window) as shown in the red boundary below:
SR
As negative numbers are stored in two’s compliment form:
To take two’s compliment of a number, following are the steps:
U
Page 2 of 3
http://lms.vusr.net
www.VUSR.net
After Executing the program, the data is now sorted in signed descending order:
SR
So, now the data is in signed descending order:
Page 3 of 3
http://lms.vusr.net