Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 18

Microprocessor & Assembly

Language

Lecture-
Addressing Modes
SIZE MISMATCH ERRORS

If we change the directive in the last example from DW to DB, the


program will still assemble and debug without errors, however the
results will not be the same as expected

 To keep the declarations and their access synchronized is the


responsibility of the programmer and not the assembler

 The assembler allows the programmer to do everything he


wants to do, and that can possibly run on the processor.

 The programmer is responsible for accessing the data as word


if it was declared as a word and accessing it as a byte if it was
declared as a byte
In the above examples, the processor knew the size
of the data movement operation from the size of the
register involved, for example in
“mov ax, [num1]” memory can be accessed as byte
or as word, it has no hard and fast size, but the AX
register tells that this operation has to be a word
operation.
Similarly in “mov al, [num1]” the AL register tells
that this operation has to be a byte operation.
However in “mov ax, bl” the AX register tells that
the
operation has to be a word operation while BL tells
that this has to be a byteoperation.
REGISTER INDIRECT ADDRESSING

We have done very elementary data access till now. Assume that the
numbers we had were 100 and not just three. This way of adding
them will cost us 200 instructions
There must be some method to do a task repeatedly on data
placed in consecutive memory cells

The key to this is the need for some register that can hold the
address of data

There are four registers in iAPX88 architecture that can hold


address of data and they are BX, BP, SI, and DI. There are
minute differences in their working which will be discussed later.
For the current example, we will use the BX register
Addressing Modes

jnz

Jump if the zero flag is not set.


Zero flag is set if the last logical or mathematical
instruction has produced a zero in its destination.
Addressing Modes

Offset Addressing

mov ax,[num1]
Addressing Modes

Register Indirect

mov ax, [bx]


Addressing Modes

Register Indirect + Offset

mov ax,[bx+num1];base + offset


mov ax,[si+num1];index + offset
Addressing Modes

Base + Index

mov ax,[bx+si]
Addressing Modes

Base + Index + Offset

mov ax,[bx+si+num1]
Addressing Modes

mov ax,[num1] ; (o) - Offset


mov ax,[bx] ; (b) - Base
mov ax,[si] ; (i) - Index
mov ax,[bx+num1] ; b+o
mov ax,[si+num1] ; i+o
mov ax,[bx+si] ; b+i
mov ax,[bx+si+num1] ; b+i+o
Segment Override Prefix

Instruction Opcode
mov ax,[cs:bx] 2E9B07
mov ax,[es:bx] 268B07
mov ax,[ss:bx] 368B07
mov ax,[bx] 8B07
By default bx has tied with DS segment.
If we want to use bx In CS segment we
write it in above format called segment
override

You might also like