# CS401 Assignment 1 solution Spring 2013

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.

Ans:-

Segment Address = Segment Register x 10.

A)    5FD1: 111E

Segment Address = 5FD1 x 10 = 5FD10

Physical Address =  5FD10 + 111E =61E2E

B)    91EF: F1F1

Segment Address = 91EF x 10 = 91EF0

Physical Address =  91EF0 + F1F1 = A2201

Question No. 2:                                                                                  Marks [10]

Write a complete assembly language code for the following program:

Initialize AX with ‘4’

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

Solution:

001

002    [org 0x0100]

003    mov ax  , 4

004    mov bx ,  9

005    mov cx ,  6

007   mov  ax,  bx

008   sub  bx ,  cx

009   mov bx,  cx

011   mov dx ,ax

012   EAX

013   [ax,dx],bx

014    mov ax, 0x4c00

015    int 0x21