100% found this document useful (1 vote)
795 views

CS401 1 Solution File

The document provides instructions for Assignment #1 of the course Computer Architecture and Assembly Language Programming. It outlines rules for marking, including that assignments must be submitted by the deadline and in .doc format. It also provides guidance to use recommended books to clarify concepts and not to upload files in the last hour before the deadline. The document includes two questions - the first asks to calculate physical addresses for two memory instructions, and the second asks to assemble and debug a sample assembly language program using the NASM assembler and AFD debugger.

Uploaded by

Ali Haider
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
795 views

CS401 1 Solution File

The document provides instructions for Assignment #1 of the course Computer Architecture and Assembly Language Programming. It outlines rules for marking, including that assignments must be submitted by the deadline and in .doc format. It also provides guidance to use recommended books to clarify concepts and not to upload files in the last hour before the deadline. The document includes two questions - the first asks to calculate physical addresses for two memory instructions, and the second asks to assemble and debug a sample assembly language program using the NASM assembler and AFD debugger.

Uploaded by

Ali Haider
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Computer Architecture and Assembly Language Programming

(CS401)
Assignment # 1(Non-Graded)
Total marks = 20
Deadline Date = May 05, 2014

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.

1) You should concern recommended books to clarify your concepts as handouts are not
sufficient.
2) You are supposed to submit your assignment in .doc format. Any other formats like scan
images, PDF, zip, rar, bmp etc will not be accepted.

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 etc.). Hence refrain from uploading assignment in
the last hour of deadline. It is recommended to upload solution file at least two days before its
closing date.
For any query, feel free to email at:
cs401@vu.edu.pk

Question No. 1:
Suppose we have the following register values:
AX = 0200h
BX = 4336h
CX = 1234h
SI = 0100h
CS = 0FE0h and
DS = E000h
You are required to calculate the physical address generated by each of the following
instructions:
1. MOV AX, [CS: BX + 100]
2. MOV CX, [BX + SI + 0x0030]
Note: Every instruction is independent of others.
Solution:
1. MOV AX, [CS:BX + 100]
The effective address will be calculated by adding the value of BX and decimal 100.
Hexadecimal representation of 100 is 64h.
Effective address (E.A)

Physical Address

= BX + 64h
= 4336h + 64h
= 439Ah

= CS x 10h + EA
= 0FE0h x 10h + 439Ah
= 0FE00h + 439Ah
= 1419Ah

2. MOV CX, [BX + SI + 0x0030]


The effective address will be calculated by adding the values of BX, SI and 0x0030.
Effective address (E.A)

= BX + SI + 0x0030
= 4336h + 0100h + 0x0030
= 4466h

Physical Address

= DS x 10h + EA
= E000h x 10h + 4466h
= E0000h + 4466h
= E4466h

Question No. 2:
Assemble the given program using NASM.
ORG 0100H
XOR AX, AX
MOV BX, 55H
MOV AX, 42
ADD AX, BX
SUB BX, 02H
ADD AX, BX
SUB AX, EA12H
MOV BX, 22H
MOV AX, 0X4C00
INT 0X21

1. After that load the Debugger by typing AFD in command prompt as in Fig 1.

Fig 1: Loading debugger.

2. The AFD window will be opened. The complete description is given below in fig 2

Fig 2: AFD description.


3. When the program is loaded in the debugger, it is loaded at offset 0100, which
displaces all memory accesses in our program. Execute the program step by step and
examine how the memory is read, the registers are updated and how the instruction
pointer moves forward.
Solution:
Instruction
1

ORG 0100H

XOR AX, AX

MOV BX, 55H

MOV AX, 42

ADD AX, BX

SUB BX, 02H

ADD AX, BX

SUB AX, 10h

Register current
value after the
instruction
execution
AX
0000
BX
0000
AX
0000
BX
0000
AX
0000
BX
0055
AX
002A
BX
0055
AX
007F
BX
0055
AX
007F
BX
0053
AX
00D2
BX
0053
AX
00C2

Flags

IP
(Instruction
Pointer)
0100

CF

ZF

PF

SF

AF

0102

0105

0108

010A

010E

0110

0113

1 MOV BX, 22H


0
11 MOV AX, 0X4C00

BX
AX
BX
AX
BX

0053
00C2
0022
4C00
0022

0116

0119

Table: Register contents after the execution of each instruction.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy