www.VUSR.
net
CS401- Computer Architecture and Assembly Language
Programming
Solution to Assignment # 2
Fall 2009
Total Marks: 20
Solution
[org 0x0100]
jmp start
data: dw 60, 55, 45, 50, 40, 35, 25, 30, 10, 0
swap: db 0
start: mov bx, 0
mov byte[swap], 0
loop1: mov ax, [data+bx]
cmp
jbe
ax, [data + bx + 2]
noswap
SR
mov dx, [data+bx+2]
mov [data+bx+2], ax
mov [data+bx], dx
mov byte[swap], 1
U
noswap: add bx, 2
cmp bx, 18
jne loop1
V
cmp byte[swap], 1
je start
mov ax, [data] ; First number is min as array is sorted in ascending order
mov dx, [data+18] ; Similarly last number is max
mov ax, 0x4c00
int 0x21
http://lms.vusr.net All VU Past Study Resource