Post AssignmentsFeedback

Assignment No.1 / Compute Architecture & Assembly Language programming
(CS 401) / Marks: 20 / Due Date: 18-04-2012
Assignment Solution:
Question No. 1:
Calculate physical address of your AFD window contains CS and IP register (segment offset pairs). Explain each and every step for calculating the physical address.
(Calculation:4 marks
Explanation:3 marks
Snapshot:3 marks )
Note: Provide snapshot of your AFD window. Please give us this type of your AFD window and mention which segment register value and offset value you have used for calculating physical address. Please see below sample snapshot.

Physical address = 1E090 + 00100 = 1E190
CS:1E090
IP:00100
Physical address : 1E190
Question No. 2:
Write a program to add these 8 numbers (15, 20, 25, 30, 35, 40, 45, and 50) with using conditional jump. Explain each instruction of program in your own words.
( Program:5 marks
Snapshot: 5 marks )
Note: Provide snapshot of your program which will be run in AFD window. It is strictly prohibited the copied assignment.
Program code
  1. [org 0x0100]
  1. mov bx, 0 ; initialize array index to zero
  1. mov ax, 0 ; initialize sum to zero
  1. l1: add ax, [addnum +bx] ; add number to ax
  1. add bx, 2 ; advance bx to next index
  1. cmp bx, 16 ; are we beyond the last index
  1. jne l1 ; if not add next number
  1. mov [totalsum], ax ; write back sum in memory
  1. mov ax, 0x4c00
; terminate program
  1. int 0x21
  1. addnum: dw 15, 20, 25, 30, 35, 40, 45,50
  1. totalsum: dw 0
Total sum (result) show in AX register

Assignment Solution Step by Step:
Q1:Calculate physical address of your AFD window contains CS and IP register (segment offset pairs). Explain each and every step for calculating the physical address.
we have to make 16-bit “segment address”(e.g. CS) to 20-bit address by adding 0 to its end and making 16-bit “offset address” (IP) to 20-bit address by adding 0 to its start, then add them to get a 20-bit physical address.
Q2: Write a program to add these 8 numbers (15, 20, 25, 30, 35, 40, 45, and 50) with using conditional jump. Explain each instruction of program in your own words.
As mentioned in Question 2, write program with using conditional jump, So no need another instruction for solving this question.
Program:
  1. Firstly initialize array index to zero (mov zero to bx register)
  2. Initialize sum to zero (mov zero to ax register)
  3. Using conditional jump, label has declared for adding number to ax and mov bx to next index, check it is not beyond the last index. If not add next number, write back total sum in memory and terminate program.
  1. F2 key is used for running all instructions one by one in AFD window. Before termination instruction, you have seen result in ax register in hexadecimal value that was 0104.

Common Mistakes & Explanation: / Mistake 1: Missed details in physical address calculation
Explanation: we have to make 16-bit “segment address”(e.g CS) to 20-bit address by adding 0 to its end and making 16-bit “offset address”(IP) to 20-bit address by adding 0 to its start, then add them to get a 20-bit physical address.
Students were expected to explain and give details regarding calculation for assessing out physical address.
Mistake 2: Snapshots missing in Question 2
Explanation: We have requested to paste/attach the final snapshot of AFD window, which shows the result of complete calculation in AX.
Alternate Solutions:
There is no alternate solution.