11-22-2012, 03:18 PM
CS401 Computer Architecture and Assembly Language Assignment No.2 Fall 2012
Assignment No. 02
Semester: Fall 2012
CS401: Computer Architecture and Assembly Language Programming
Total Marks: 20
Due Date:26 Nov,2012
Due Date:
Your assignment must be uploaded/submitted before or on 26 November 2012
Uploading instructions:
Please view the Assignment Submission Process document provided to you by the Virtual University for uploading assignments.
• Assignment should be in .doc format.
• Save your assignment with your ID (e.g. bx020200786.doc).
• Assignment submission through email is highly discouraged.
Rules for Marking:
It should be clear that your assignment will not get any credit if:
• The assignment is submitted after due date.
• The submitted assignment file is corrupted.
• The assignment is copied.
Note:
Your answer must follow the below given specifications. You will be assigned zero marks if you do not follow these instructions.
o Font style: “Times New Roman”
o Font color: “Black”
o Font size: “12”
o Bold for heading only.
o Font in Italic is not allowed at all.
o No formatting or bullets are allowed to use.
Objective
The objective of this assignment is to enhance your knowledge about;
Subroutines
How to execute Subroutine Program
Assignment No. 2
Question No. 1:
Assemble the given Subroutine program using NASM (Netwide Assembler) to add 10 numbers array using a subroutine named as “sumofarray” and show the changes occurs in AX, BX & CX on each step.
(10 marks)
[ORG 0x0100]
MOV BX, VAL
MOV CX, 3
MOV AX, 0
CALL SUMOFARRAY
MOV AX, 0X4C00
INT 0X21
SUMOFARRAY: ADD AX, [BX]
ADD BX, 2
SUB CX, 1
JNZ SUMOFARRAY
MOV [SUM], AX
RET
VAL: DW 30,40,50
SUM: DW 0
Note: Execute this program with F2 key (instruction will move one by one) and using F1 key is used to trace the call subroutine. Write down the contents of the specified registers in the given table.
Instruction Register current value after the instruction execution IP
(Instruction Pointer) Flags
CF ZF PF SF AF
1 [ORG 0x0100] AX
BX
CX
2 MOV BX, VAL AX
BX
CX
3 MOV CX, 3 AX
BX
CX
4 MOV AX, 0 AX
BX
CX
5 CALL SUMOFARRAY
6 MOV AX, 0X4C00
7 INT 0X21
8
SUMOFARRAY:
ADD AX, [BX] AX
BX
CX
ADD BX, 2 AX
BX
CX
SUB CX, 1 AX
BX
CX
9
SUMOFARRAY:
ADD AX, [BX]
AX
BX
CX
ADD BX,2 AX
BX
CX
SUB CX,1 AX
BX
CX
10
SUMOFARRAY:
ADD AX, [BX]
AX
BX
CX
ADD BX,2 AX
BX
CX
SUB CX,1 AX
BX
CX
11 MOV [SUM], AX AX
BX
CX
Question No. 2:
After attempting previous question, you are now able to write, assemble and debug a Subroutine program. Write an assembly language code to find the minimum number from an array of ten numbers using a subroutine. Explain each instruction of program in your own words and also attach the snapshot of your AFD (A Fullscreen Debugger) showing the executed code of final results.
(10 marks)
(Program using subroutine: 5 marks, Explanation: 3 marks, Snapshot: 2 marks)
Note: Provide snapshot of your program which will be run in AFD window. It is strictly prohibited the copied assignment.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
