CS401 Assignment Solution By Instructor

No Comments

Computer Architecture and Assembly language programming (CS401)
Assignment # 1

  Total marks = 20
                                                                                    Deadline Date = Expired

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. Students will be punished severely in either case.


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.
3)      You are advised to upload your assignment at least two days before the due date.
4)      The assignment file comprises of two pages.


Note: 

Assignment comprises of lectures No. 1-7.

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 deadline.

For any query, feel free to email at:

Question No. 1:                                                                                  Marks [5+5]

Calculate physical address for the following segment-offset pairs:
  1. 5FD1: 111E
  2. 91EF: F1F1

Briefly explain each step.

Solution:                                                                                            

  1. 5FD1: 111E

5FD1 is our segment address which needs to be converted to 20 bits by appending four zero’s on its right side as follows:
5FD10

111E is our offset address which also needs to be converted to 20 bits by appending four zero’s on its left side as follows:
0111E

Now we can add both segment and offset addresses in order to get physical address as follows:
5FD10 + 0111E = 60E2E             


  1. 91EF: F1F1

91EF is our segment address which needs to be converted to 20 bits by appending four zero’s on its right side as follows:
91EF0

F1F1 is our offset address which also needs to be converted to 20 bits by appending four zero’s on its left side as follows:
0F1F1

Now we can add both segment and offset addresses in order to get physical address as follows:
91EF0 + 0F1F1 = A10E1








Question No. 2:                                                                                  Marks [10]

Write a complete assembly language code for the following program:

  1. Initialize AX with ‘4’
  2. Move ‘9’ to BX
  3. Move ‘6’ to CX
  4. Add AX with BX and store the result in AX
  5. Subtract CX from BX and store the result in BX
  6. Add AX with BX and the store the result in DX
  7. Invert the contents of AX register
  8. Perform AND operation on AX and DX registers; store the result in BX register.

Solution:

[ORG 0X0100]

  1. MOV AX, 4
  2. MOV BX, 9
  3. MOV CX, 6

  1. ADD AX, BX

  1. SUB BX, CX

  1. MOV DX, BX
ADD DX, AX

  1. NOT AX

  1. AND AX, DX
MOV BX, AX

MOV AX, 0X4C00
INT 0X21



The End
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment