CS401 Assignment No 1 Solution


CS401 - Computer Architecture and Assembly Language Programming Assignment No. 1


CS401 Assignment  Solution

CS401 Assignment Part 1.

You are required to calculate Physical Addresses for the following two combinations:
1.      BX+SI+0xFF00
2.      BP+DI+0xA000


First of all wo calculate the Effective Address(EF).
In snapshot the value of BX = 0000 and SI = 01A2
Effective Address =  BX + SI + 0x0FF00
EF = 0000 + 01A2 + 0x0FF00
EF = 100A2
Now we compute the Physical Address
For BX and SI the default segment is DS
In snapshot the value of DS = 0A2E

Physical Address = DS * 10H + EF
Physical Address = 0A2E*10H + 100A2
Physical Address = A2E0 + 100A2
Physical Address = 1A382H

CS401 Assignment Part 2.

Question 2:
Assume the following Pseudo Code and convert it into proper assembly language instructions that should be assembled and debugged using NASM.

1.      Declare an array named as P_NUM of 5 elements that contains first five prime numbers.
2.      Set CX to 5 in decimal.
3.      Move the first element of P_NUM array to the AX.
4.      Move the fourth element of P_NUM array to the BX.
5.      Move last element from P_NUM array to the DX.
6.      Add the values of AX and BX and store the result in AX.
7.      Add the values of new AX and DX and store the result in BX.

  1. BP+DI+0xA000
In snapshot the value of BP = 0000 and DI = 000A
Now the calculate the Effective Address(EF).

Effective Address = BP+DI+0xA000
EF = 0000 + 000A + 0x0A000
EF = A00A
Now we compute the Physical Address
In snapshot the Default segment of  BP is SS
The value of SS is given in snapshot SS = 12A1

Physical Address = SS*10H + EF
Physical Address = 12A1*10 + A00A
Physical Address = 12A10 + A00A
Physical Address = 1CA1A
Answer 2.

[org 0x100]

mov cx, 5
mov ax, [P_NUM]
mov bx, [P_NUM+6]
mov dx, [P_NUM+8]

add ax,bx
add ax,dx

mov bx, ax

mov ax, 0x4c00
int 0x21

P_NUM:   dw 2,3,5,7,11


Post a Comment