Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
39 views

Computer Architecture and Assembly Language Programming - CS401 Fall 2009 Assignment 02 Solution

The document is a solution to a computer architecture and assembly language programming assignment. It contains code in assembly language that sorts an array of numbers in ascending order using a swap flag and loop, and then displays the minimum and maximum values in the sorted array by comparing the first and last elements. The code loops through the array, swaps elements if out of order, sets a swap flag, and repeats the sort loop until no swaps are needed.

Uploaded by

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

Computer Architecture and Assembly Language Programming - CS401 Fall 2009 Assignment 02 Solution

The document is a solution to a computer architecture and assembly language programming assignment. It contains code in assembly language that sorts an array of numbers in ascending order using a swap flag and loop, and then displays the minimum and maximum values in the sorted array by comparing the first and last elements. The code loops through the array, swaps elements if out of order, sets a swap flag, and repeats the sort loop until no swaps are needed.

Uploaded by

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

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

You might also like