Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

MODULE-2 - AddressingModes - Part 2

The document discusses various addressing modes of the 8086 microprocessor like direct, register indirect, register relative, based indexed and relative based indexed addressing. It provides examples of instructions like MOV that use these addressing modes along with details of how the effective address is calculated in each mode. Segment registers and their usage is also covered.

Uploaded by

eshwar211104
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

MODULE-2 - AddressingModes - Part 2

The document discusses various addressing modes of the 8086 microprocessor like direct, register indirect, register relative, based indexed and relative based indexed addressing. It provides examples of instructions like MOV that use these addressing modes along with details of how the effective address is calculated in each mode. Segment registers and their usage is also covered.

Uploaded by

eshwar211104
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Module – 2:

MICROPROCESSOR ARCHITECTURE
& INTERFACING : INTEL x86
• An instruction is a basic command given to a microprocessor to perform a specified
operation with given data.
• Each instruction has two groups of bits.
• One group of bits is known as operation code (Opcode), which defines what operation will
be performed by the instruction.
• The other field is called operand, which specifies data that will be used in arithmetic and
logical operations.
• The operand can specify a register or a memory location in any one of the memory segments
or I/O ports.
• The addressing mode is used to locate the operand or data.
• There are different types of addressing modes depending upon the location of data in the
8086 processor.
• Most 8086 instructions can operate on the 8086’s general purpose register set.

• By specifying the name of the register as an operand to the instruction, you may access the

contents of that register.

• Consider the 8086 mov (move) instruction:

mov destination, source

• This instruction copies the data from the source operand to the destination operand.

• The eight and 16 bit registers are certainly valid operands for this instruction.

• The only restriction is that both operands must be the same size.
mov ax, bx ;Copies the value from BX into AX

mov dl, al ;Copies the value from AL into DL

mov si, dx ;Copies the value from DX into SI

mov sp, bp ;Copies the value from BP into SP

mov dh, cl ;Copies the value from CL into DH


• In addition to the general purpose registers, many 8086 instructions (including the mov instruction)
allow you to specify one of the segment registers as an operand.
• There are two restrictions on the use of the segment registers with the mov instruction.
• First of all, you may not specify cs as the destination operand,
• second, only one of the operands can be a segment register.
• You cannot move data from one segment register to another with a single mov instruction.
• To copy the value of cs to ds, you’d have to use some sequence like:
mov ax, cs
mov ds, ax
• You should never use the segment registers as data registers to hold arbitrary values.
• They should only contain segment addresses
• Immediate addressing transfers the source, an immediate byte or word data, into the
destination register.
• Immediate data means constant data, whereas data transferred from a register or memory
location are variable data.
• Immediate date may be 8-bit or 16 bit.
• Example: MOV BL, 44 ; Copies 44 decimal (2CH) into BL
MOV AX, 44H ; Copies 0044H into AX
MOV AL, ‘A’ ; Copies ASCII of the letter A into AL
• A 16-bit memory address (offset) or an IO address is specified directly in the instruction.
• Eg. MOV AX, [5000H]; Data resides in a memory location in the data segment, whose effective
address is computed using 5000H as offset and the content of DS as segment address
• IN AL, 80H ; AL gets data from I/O port address 80H.

• IN AX, 80H ; AX gets 16-bit data from I/O port address 80H

• OUT 80H, AL ; I/O port 80H gets 8-bit data from AL

• OUT 80H, AX ; I/O port 80H gets 16-bit data from AX

• This is also called Fixed Port Addressing.


If we use 16-bit I/O address we get a range of 0000H--FFFFH. This gives a total of
65536 I/O ports. Here we use Indirect addressing Mode, that is, the I/O address is
specified by DX register.
• MOV DX, 2080H
• IN AL, DX ; AL gets data from I/O port address 2080H given by DX.
• IN AX, DX ; AX gets 16-bit data from I/O port address given by DX.
• OUT DX, AL ; I/O port whose address is given by DX gets 8-bit data from AL
• OUT DX, AX ; I/O port whose address is given by DX gets 16-bit data from AX
• This is also called Variable Port Addressing.
• In the Register addressing mode, the data is stored in a register and it is referred using
a particular register.
• All registers except IP may be used in this mode.
• 8-bit register names with register addressing: AH, AL, BH, BL, CH, CL, DH, DL.
• 16-bit register names: AX, BX, CX, DX, SP, BP, SI ,DI, CS, SS, DS and ES.
• Never mix an 8-bit register with 16-bit, it is not allowed in microprocessor.
• Code segment register (CS) is never used as destination.
• Segment to segment MOV instruction is not allowed.
• Examples:
MOV AL, BL ; Copies 8-bit content of BL into AL
MOV AX, CX ; Copies 16-bit content of CX into AX
MOV ES, DS ; Not allowed (segment to segment)
MOV BL, DX ; Not allowed (mixed size)
MOV CS, AX ; Not allowed (Code segment register may not be destination register)
• The address of the memory location which contains data is determined in an indirect way,
using the offset registers.
• The offset address of data is stored in BX, DI and SI.
• The data segment or extra segment is used by default
• The [ ] symbol denote indirect addressing in assembly language.
Example:
• MOV CX, [BX] ; Copies the word contents of the data segment memory location addressed by
BX into CX.
• MOV [DI], [BX] ; Memory to memory transfers are not allowed except with string inst.
• In this addressing mode, the offset address of the operand is given by the sum of contents of
the Base (BX/BP) registers and 8-bit/16-bit displacement.
• The effective address of the data is formed, in this addressing mode, by adding the content of
a base register (any one of BX or BP) to the content of an index register (any one of
SI or DI)
• The default segment register may be DS or ES
Example:
• MOV DX, [BX+04]
• ADD CL, [BX+08]
• MOV AX, 50H[BX] ; Effective address is given as DS*10H + 50H + [BX] .
• MOV 10H[SI], DX ; Content of DX is transferred to address DS*10H + 10H + [SI]
• Offset of the operand is stored in one of the index registers.
• DS is the default segment register for DI and SI.
• In case of string instruction, DS and ES are default segment registers for SI & DI respectively.
• This is a special case of register indirect addressing mode.
• Example:
• MOV AX, [SI] ; Data is available in data segment, at an offset address stored in SI .
• MOV CX, [DI] ; Content of address DS*10H + [DI] will be transferred to CX
• In this addressing mode, data is available at an effective address formed by adding the
content of any one of the base registers (BP or BX) to the content of an index
register (SI or DI).
• The default segment may be DS or ES.
• Example:
• MOV AX, [BX] [SI] ; Effective address is given as DS*10H + [BX] + [SI].
• MOV [BX] [DI], AX ; Content of AX is transferred to address DS*10H + [BX] + [DI]
• The effective address is formed by adding an 8-bit or 16-bit displacement with the sum of
contents of any one of the base registers (BP or BX) and any one of the index registers (SI or
DI).
• The default segment may be DS or ES.
• Example:
• MOV AX, 50H [BX] [SI] ; Effective address is given as DS*10H + 50H + [BX] + [SI].
• ADD 50H [BX] [SI], BP ; Content of BP is added with that in the memory location whose offset
is given by DS*10H + 50H + [BX] + [SI], result is stored in this memory location.
• The content of the segment register is shifted left bit-wise four times (Multiply the 16-bit hex
value by 10H).
• To this result, the content of an offset register is added, to produce 20-bit physical
address.
• Offset registers for the different segments are indicated below:
• BX/ SI/ DI – Data Segment/ Extra Segment
• IP – Code Segment
• BP – Starting address of Stack
• SP – Top of stack
The value of Code Segment (CS) Register is 4042H and the value of different
offsets is as follows: BX: 2025H , IP: 0580H , DI: 4247H. Calculate the
effective address of the memory location pointed by the CS register.
• The offset of the CS Register is the IP register.
• Shift base address 4-bits and Add offset address

= (409A0)H
• The value of the DS register is 3032H. And the BX register contains
3040H. Find the physical address.

 33360H
• You are provided with the following values:
DS: 3056H, IP: 1023H, BP: 2322H and SP: 3029H.
Can you calculate the effective address of the memory location as per the DS
register?
i. Direct Addressing: MOV AX, [5000H]
ii. Register Indirect: MOV AX, [BX]
iii. Register Relative: MOV AX, 5000H [BX]
iv. Based Indexed: MOV AX, [BX] [SI]
v. Relative Based Indexed: MOV AX, 5000H [BX] [SI]

You might also like