0% found this document useful (0 votes)
8 views

Lecture 8 - Program Memory Addressing Modes

Program Memory Addressing mode

Uploaded by

talha4400573
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)
8 views

Lecture 8 - Program Memory Addressing Modes

Program Memory Addressing mode

Uploaded by

talha4400573
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/ 17

Microprocessor

Programming and Interface


Dr. Saad Qasim Khan
Assistant Professor
CIS Department NEDUET
saadqasimkhan@neduet.edu.pk
Base relative-plus-index addressing
• Base relative-plus-index addressing transfers a byte or word between
a register and the memory location addressed by a base and an index
register plus a displacement. (Example: MOV AX, ARRAY[BX+DI] or
MOV AX, [BX+DI+4]. These instructions load AX from a data segment
memory location. The first instruction uses an address formed by
adding ARRAY, BX, and DI and the second by adding BX, DI, and 4.)

Lecture 8 2
Lecture 8 3
Lecture 8 4
Lecture 8 5
Assembly language parts
• Each statement in an assembly language program
consists of four parts or fields,
• The leftmost field is called the label and it is used
to store a symbolic name for the memory location
that it represents.
• The next field to the right is called the opcode field;
it is designed to hold the instruction, or opcode.
• To the right of the opcode field is the operand field,
which contains information used by the opcode.
• The final field, the comment field, contains a
comment about an instruction or a group of
instructions. A comment always begins with a
semicolon (;).

Lecture 7 6
PROGRAM MEMORY-ADDRESSING MODES
• Program memory-addressing modes, used with the JMP (jump) and
CALL instructions, consist of three distinct forms:
• direct,
• relative, and
• indirect.
• This section introduces these three addressing forms, using the JMP
instruction to illustrate their operation.

Lecture 8 7
Direct Program Memory Addressing
• Direct program memory addressing is what many early
microprocessors used for all jumps and calls. Direct program memory
addressing is also used in high-level languages, such as the BASIC
language GOTO and GOSUB instructions. The microprocessor uses
this form of addressing, but not as often as relative and indirect
program memory addressing are used.
• The instructions for direct program memory addressing store the
address with the opcode. For example, if a program jumps to memory
location 10000H for the next instruction, the address (10000H) is
stored following the opcode in the memory.

Lecture 8 8
Example

Figure 3–14 shows the direct intersegment JMP instruction and the 4 bytes required to store the address 10000H.
This JMP instruction loads CS with 1000H and IP with 0000H to jump to memory location 10000H for the next instruction.

Lecture 8 9
Intersegment Jump
• (An intersegment jump is a jump to any memory location within the
entire memory system.) The direct jump is often called a far jump
because it can jump to any memory location for the next instruction.
• In the real mode, a far jump accesses any location within the first 1M
byte of memory by changing both CS and IP.
• The only other instruction that uses direct program addressing is the
intersegment or far CALL instruction. Usually, the name of a memory
address, called a label, refers to the location that is called or jumped
to instead of the actual numeric address. When using a label with the
CALL or JMP instruction, most assemblers select the best form of
program addressing.

Lecture 8 10
Relative Program Memory Addressing
• Relative program memory addressing is not available in all early
microprocessors, but it is available to this family of microprocessors.
The term relative means “relative to the instruction pointer (IP).” For
example, if a JMP instruction skips the next 2 bytes of memory, the
address in relation to the instruction pointer is a 2 that adds to the
instruction pointer.
• Notice that the JMP instruction is a 1-byte instruction, with a 1-byte
or a 2-byte displacement that adds to the instruction pointer. A 1-
byte displacement is used in short jumps, and a 2-byte displacement
is used with near jumps and calls. Both types are considered to be
intrasegment jumps.

Lecture 8 11
Example

Lecture 8 12
Intrasegment jump
• An intrasegment jump is a jump anywhere within the current code
segment.
• Relative JMP and CALL instructions contain either an 8-bit or a 16-bit
signed displacement that allows a forward memory reference or a reverse
memory reference.
• All assemblers automatically calculate the distance for the displacement
and select the proper 1-, 2- or 4-byte form. If the distance is too far for a 2-
byte displacement in an 8086 through an 80286 microprocessor, some
assemblers use the direct jump. An 8-bit displacement (short) has a jump
range of between +127 and -128 bytes from the next instruction; a 16-bit
displacement (near) has a range of ±32K bytes.
Lecture 8 13
Indirect Program Memory Addressing
• The microprocessor allows several forms of program indirect memory
addressing for the JMP and CALL instructions.
• Program indirect jump instructions, which can use any 16-bit register
(AX, BX, CX, DX, SP, BP, DI, or SI); any relative register ([BP], [BX], [DI],
or [SI]); and any relative register with a displacement.

Lecture 8 14
Lecture 8 15
Lecture 8 16
The End

Lecture 8 17

You might also like