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

Fall 2021 - CS401P - 2

The document provides instructions for Assignment 2 in the course Computer Architecture and Assembly Language Programming. It states that students must write an assembly language program to sort the digits of their VU ID using selection sort. The program must store the VU ID numbers in memory, sort them in ascending order using selection sort, and write the sorted ID back to memory. Students must save the file with the first four digits of their VU ID and submit a single zip file containing the assembly program and a GIF showing the assembly and debugging process. The deadline for submission is January 4th, 2022. Late submissions or those not following the specified format and instructions will not receive credit.

Uploaded by

ahali001111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Fall 2021 - CS401P - 2

The document provides instructions for Assignment 2 in the course Computer Architecture and Assembly Language Programming. It states that students must write an assembly language program to sort the digits of their VU ID using selection sort. The program must store the VU ID numbers in memory, sort them in ascending order using selection sort, and write the sorted ID back to memory. Students must save the file with the first four digits of their VU ID and submit a single zip file containing the assembly program and a GIF showing the assembly and debugging process. The deadline for submission is January 4th, 2022. Late submissions or those not following the specified format and instructions will not receive credit.

Uploaded by

ahali001111
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Architecture and Total marks = 20

Assembly Language Programming


Practical (CS401P) Deadline Date:

Assignment No. 2 04 January 2022

Please carefully read the following instructions before attempting assignment.

RULES FOR MARKING


It should be clear that your assignment would not get any credit if:

 The assignment is submitted after the due date.


 The submitted assignment does not open or file is corrupt.
 Strict action will be taken if submitted solution is copied from any other student or from the
internet.

You should concern the recommended books to clarify your concepts as handouts are not sufficient.

You are supposed to submit your assignment in .zip or rar format.

Any other formats like scan images, PDF, doc, docx, ppt and bmp etc. will not be accepted.

Lectures covered: 1-6

Topics covered: Indirect Addressing

NOTE

No assignment will be accepted after the due date via email in any case (whether it is the case of load
shedding or internet malfunctioning). Hence refrain from uploading assignment in the last hour of the
deadline. It is recommended to upload your solution file at least two days before its closing date.

If you find confusion in the assignment (Question statement), please contact your instructor before the
deadline. After the deadline, no queries will be entertained in this regard.

For any query, feel free to email at [email protected]


Write an assembly language program that sort digits from your VU id using selection sort:
 First store numbers of your VUID in the memory variable(array).
 Sort VUID in the ascending order using selection sort.
 After sorting each number write back to same variable declared initially.
 At the end of program the sorted id must be stored in memory.

Note: Save the .asm file with first four digits of your VUID.asm. You must use your own VUID
otherwise assignment will not be accepted.

Submission details:

Following are required in a single zipped file

 Assembly language program.


 GIF showing complete process of assembling and debugging.

“Best of luck”
Solution

; sorting a list of ten numbers using bubble sort


[org 0x0100]
jmp start
vuid: dw 6, 5, 7, 4, 9, 1, 4, 8, 2, 0
swap: db 0

start: mov di, 0 ; set index to zero


mov byte [swap], 0 ; set swap flag to no swaps
check: mov ax, [vuid+di] ; move the digit of vuid in the ax
cmp ax, [vuid+di+2] ; compare the digit of vuid with its next digit
jbe noswap ; jump to noswap, if there is no need of swapping
mov bx, [vuid+di+2] ; move second digit in bx
mov [vuid+di+2], ax ; swap first digit in second
mov [vuid+di], bx ; swap second digit in first
mov byte [swap], 1 ; set the flag that a swap has been done
noswap: add di, 2 ; add 2 in bx
cmp di, 18 ; check if we are at last index
jne check ; if not compare next two
cmp byte [swap], 1 ; check if a swap has been done
je start ; if yes make another pass
end: mov ax, 0x4c00 ; terminate program
int 0x21

You might also like