CS401 1 Solution File
CS401 1 Solution File
(CS401)
Assignment # 1(Non-Graded)
Total marks = 20
Deadline Date = May 05, 2014
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
= 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.
2. The AFD window will be opened. The complete description is given below in fig 2
ORG 0100H
XOR AX, AX
MOV AX, 42
ADD AX, BX
ADD AX, BX
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
BX
AX
BX
AX
BX
0053
00C2
0022
4C00
0022
0116
0119