0% found this document useful (0 votes)
68 views6 pages

COAL Lab Manual 3

The document discusses different types of registers in x86 architecture including general purpose, pointer, and segment registers. It also describes different variable types (byte, word, double word) and how to view memory contents using DOSBOX. Direct addressing mode is explained as accessing memory at a fixed offset using brackets. Examples are provided to read from and write to memory using direct addressing with mov instructions. The practice task asks the reader to write a program that uses direct addressing to access predefined variables, sum their values, and store the result in the ax register.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views6 pages

COAL Lab Manual 3

The document discusses different types of registers in x86 architecture including general purpose, pointer, and segment registers. It also describes different variable types (byte, word, double word) and how to view memory contents using DOSBOX. Direct addressing mode is explained as accessing memory at a fixed offset using brackets. Examples are provided to read from and write to memory using direct addressing with mov instructions. The practice task asks the reader to write a program that uses direct addressing to access predefined variables, sum their values, and store the result in the ax register.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer Organization and Assembly Language

Lab 03
Topic 1. Direct Addressing Mode with variations.

PART 1
Types of Registers:-
The registers are grouped into three categories:-
1. General Purpose registers
1.1. Data registers
1.1.1. AX is the primary accumulator.
1.1.2. BX is known as the base register.
1.1.3. CX is known as the count register.
1.1.4. DX is known as the data register.
1.2. Pointer registers
1.2.1.Instruction Pointer IP
1.2.2. Stack Pointer SP
1.2.3. Base Pointer BP
1.3. Index registers
1.3.1. Source Index SI
1.3.2. Destination Index DI
2. Control registers
2.1. Instruction Pointer and Flag register
3. Segment registers
3.1. Code Segment CS
3.2. Data Segment DS
3.3. Stack Segment SS
3.4. Extra Segment ES
Types of variables

Type No. of bits Example declaration:

Byte 8 Num1: db 43
Word=> 2 bytes 16 Num2: dw 0xABFF
double word=> 2 words 32 Num3: dd 0xABCDEF56
Note: size of both operands must be same for any type of instruction.

For example:
Mov ax,dh ;is wrong because destination is 2 bytes and source is 1 byte.

Viewing memory in DOSBOX

Areas highlighted in red( memory 1) “m1” and blue (memory 2) “m2” are showing
the memory contents. Note: Two copies of the same memory is displayed in the
given windows.

Area highlighted with yellow is showing the ascii values of the contents displayed
in the memory m2.
Viewing sample variable in memory.

 To view memory from window m2 run the command “m2 ds:Addressofvariable”


example: m2 ds:011F
 A variable with name “num1” is initialized at memory location 11F with value 65
decimal.
41 hex = 65 decimal is the ascii of “A”.
Direct Addressing Mode
Direct
A fixed offset is given in brackets and the memory at that offset is
accessed. For example “mov [1234], ax” stores the contents of the  Mov ax,[num1]
;reading
AX registers in two bytes starting at address 1234 in the current data  Mov [num2],ax ;writing
segment. The instruction “mov [1234], al” stores the contents of the
AL register in the byte at offset 1234.

Execute every part of Question 1 in Nasm with Dosbox and observe the memory
variables and register values.
Example 1.
Example 2

Example 3
Practice Tasks
Write a program to solve the following:

Use Direct addressing mode to access memory variables:


Let
Var1=10
Var2=20
Var3=2
Var4=50
Var5=90

Save the sum of these (using Direct addressing mode) Five variables (Var1+
Var2+ Var3+ Var4+Var5) in ax.

NOTE: Execute the code in sequence.

You might also like