11-24-2014, 02:38 PM
CS401 Computer Architecture and Assembly Language Programming Assignment No. 01 Discussion and Solution Fall 2014 Due Date Nov 24, 2014
We have the following register values:
AX = 420AH,
BX = A12EH,
DS = 22EAH,
CS = 0100H,
ES = 0FEAH,
SS = 0FE0H,
SI = 0010,
BP = 02ACH and
DI = 0300H.
You are required to calculate the physical address generated by each of the following instructions?
mov [bx+si+di],ax
ADD AX,[BP+12]
Note: Every instruction is independent of others.
Question No. 2: (10 marks)
Assemble the given program using NASM.
[ORG 0X0100]
MOV CX, 5
XOR AX, AX
MOV BX, NUM
L1: ADD AX, [BX]
ADD BX, 2
SUB CX, 1
JNZ L1
MOV [SUM], AX
MOV AX, 0X4C00
INT 0X21
NUM: DW 0, 1, 2, 3, 4.
SUM: DW 0
[ATTACH=CONFIG]24151[/ATTACH]
After that load the Debugger by typing AFD in the command prompt like in Fig 1.
Fig 1: Loading debugger.
The AFD window will be opened. The complete description is given below in fig 2
Fig 2: AFD description.
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 and the registers are updated, how the instruction pointer moves forward.
Now we execute the program with F2 key (instruction will move one by one) and write down the contents of the specified registers in the given table
Instruction
Register current value after the instruction execution
IP
(Instruction Pointer)
Flags
OF
CF
ZF
PF
SF
AF
1
[ORG 0X0100]
AX
BX
CX
DX
2
MOV CX, 10
AX
BX
CX
DX
3
XOR AX, AX
AX
BX
CX
DX
4
MOV BX, NUM
AX
BX
CX
DX
5
ADD AX, [BX]
AX
BX
CX
DX
6
ADD BX, 2
AX
BX
CX
DX
7
SUB CX, 1
AX
BX
CX
DX
8
JNZ L1
AX
BX
CX
DX
9
ADD AX, [BX]
AX
BX
CX
DX
10
ADD BX, 2
AX
BX
CX
DX
11
SUB CX, 1
AX
BX
CX
DX
12
JNZ L1
AX
BX
CX
DX
13
ADD AX, [BX]
AX
BX
CX
DX
14
ADD BX, 2
AX
BX
CX
DX
15
SUB CX, 1
AX
BX
CX
DX
16
JNZ L1
AX
BX
CX
DX
17
ADD AX, [BX]
AX
BX
CX
DX
18
ADD BX, 2
AX
BX
CX
DX
19
SUB CX, 1
AX
BX
CX
DX
20
JNZ L1
AX
BX
CX
DX
21
ADD AX, [BX]
AX
BX
CX
DX
22
ADD BX, 2
AX
BX
CX
DX
23
SUB CX, 1
AX
BX
CX
DX
24
JNZ L1
AX
BX
CX
DX
25
MOV [SUM], AX
AX
BX
CX
DX
26
MOV AX, 0X4C00
AX
BX
CX
DX
27
INT 0X21
AX
BX
CX
DX
Table: Register contents after the execution of each instruction.
We have the following register values:
AX = 420AH,
BX = A12EH,
DS = 22EAH,
CS = 0100H,
ES = 0FEAH,
SS = 0FE0H,
SI = 0010,
BP = 02ACH and
DI = 0300H.
You are required to calculate the physical address generated by each of the following instructions?
mov [bx+si+di],ax
ADD AX,[BP+12]
Note: Every instruction is independent of others.
Question No. 2: (10 marks)
Assemble the given program using NASM.
[ORG 0X0100]
MOV CX, 5
XOR AX, AX
MOV BX, NUM
L1: ADD AX, [BX]
ADD BX, 2
SUB CX, 1
JNZ L1
MOV [SUM], AX
MOV AX, 0X4C00
INT 0X21
NUM: DW 0, 1, 2, 3, 4.
SUM: DW 0
[ATTACH=CONFIG]24151[/ATTACH]
After that load the Debugger by typing AFD in the command prompt like in Fig 1.
Fig 1: Loading debugger.
The AFD window will be opened. The complete description is given below in fig 2
Fig 2: AFD description.
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 and the registers are updated, how the instruction pointer moves forward.
Now we execute the program with F2 key (instruction will move one by one) and write down the contents of the specified registers in the given table
Instruction
Register current value after the instruction execution
IP
(Instruction Pointer)
Flags
OF
CF
ZF
PF
SF
AF
1
[ORG 0X0100]
AX
BX
CX
DX
2
MOV CX, 10
AX
BX
CX
DX
3
XOR AX, AX
AX
BX
CX
DX
4
MOV BX, NUM
AX
BX
CX
DX
5
ADD AX, [BX]
AX
BX
CX
DX
6
ADD BX, 2
AX
BX
CX
DX
7
SUB CX, 1
AX
BX
CX
DX
8
JNZ L1
AX
BX
CX
DX
9
ADD AX, [BX]
AX
BX
CX
DX
10
ADD BX, 2
AX
BX
CX
DX
11
SUB CX, 1
AX
BX
CX
DX
12
JNZ L1
AX
BX
CX
DX
13
ADD AX, [BX]
AX
BX
CX
DX
14
ADD BX, 2
AX
BX
CX
DX
15
SUB CX, 1
AX
BX
CX
DX
16
JNZ L1
AX
BX
CX
DX
17
ADD AX, [BX]
AX
BX
CX
DX
18
ADD BX, 2
AX
BX
CX
DX
19
SUB CX, 1
AX
BX
CX
DX
20
JNZ L1
AX
BX
CX
DX
21
ADD AX, [BX]
AX
BX
CX
DX
22
ADD BX, 2
AX
BX
CX
DX
23
SUB CX, 1
AX
BX
CX
DX
24
JNZ L1
AX
BX
CX
DX
25
MOV [SUM], AX
AX
BX
CX
DX
26
MOV AX, 0X4C00
AX
BX
CX
DX
27
INT 0X21
AX
BX
CX
DX
Table: Register contents after the execution of each instruction.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
