# CS401 Computer Architecture and Assembly Language Programming Assignment 1 Solution

Suppose we have the following register values:

AX = 0200h

BX = 4336h

CX = 1234h

SI = 0100h

CS = 0FE0h   and

DS = E000h

You are required to calculate the physical address generated by each of the following instructions:

1. MOV AX, [CS: BX + 100]
2. MOV CX, [BX + SI + 0x0030]

Note: Every instruction is independent of others.

Solution: 1)

=43364+0x0000+100

=0x0001+0x0000+0x0110

=0x0110

+OfEoh*0x10+0x0110

Question No. 2:

Assemble the given program using NASM.

ORG 0100H

XOR AX, AX

MOV BX, 55H

MOV AX, 42

SUB BX, 02H

SUB AX, EA12H

MOV BX, 22H

MOV AX, 0X4C00

INT 0X21

1. After that load the Debugger by typing AFD in command prompt as in Fig 1.

The AFD window will be opened. The complete description is given below in fig 2

1. 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, the registers are updated and how the instruction pointer moves forward.
1. 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 table given below.

Table: Register contents after the execution of each instruction.

Solution: