0% found this document useful (0 votes)
20 views25 pages

L3 8086 Addressing

The document provides an overview of the Intel 8086 microprocessor, focusing on assembly level programming and data addressing modes. It explains the transition from binary to assembly language for easier software development and details various addressing modes such as register, immediate, direct, and displacement addressing. Additionally, it describes how instructions are structured and the importance of specifying data sizes during operations.

Uploaded by

ishapramod1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views25 pages

L3 8086 Addressing

The document provides an overview of the Intel 8086 microprocessor, focusing on assembly level programming and data addressing modes. It explains the transition from binary to assembly language for easier software development and details various addressing modes such as register, immediate, direct, and displacement addressing. Additionally, it describes how instructions are structured and the importance of specifying data sizes during operations.

Uploaded by

ishapramod1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Intel 8086

Microprocessor
Data Addressing
Modes
Assembly Level Programming

o We have already discussed software is nothing but binary


patterns representing code (instructions) and data
o These patterns will be decoded by the control logic of the
processor and accordingly control signals will be activated and
data will be moved around
o For humans writing software in binary is quite challenging and
extremely error prone
o This led to the development of assembly level programming
(ALP)
o Later for better productivity, we moved to high-level programming
2
Assembly Level Programming

o Remember for out fictitious processor, we had a binary pattern


0020H
to store the number 0x20 in register 0
o This binary (hexadecimal) representation of program is what we
refer as machine code
o For humans (neurotypicals), it will be easier to remember this
operation using mnemonics (expressions similar to natural
languages) rather than the actual binary pattern
MOV R0,20H
o This considerably improves productivity, reduces errors and makes 3
debugging much easier
Assembly Level Programming

o Programs written using mnemonics are called assembly level


programs
o But ultimately programs should be in machine code since that is
the language understood by the processor
o Hence somebody should convert assembly level programs to
machine code before executing it
o It could be done manually (still quite error-prone) called hand-
assembling or with the help of computers with a special program
called the assembler
o Similarly, disassembler converts machine code to assembly level
program 4
Assembly Level Programming

o Instructions written in assembly usually will have two parts


MOV destination, source

Opcode Operand
s
o opcode (stands for operational code) corresponds to the
operation the processor needs to carry out
o And the operations are carried out on operations
o Again, coming back to the definition of software as collection of
code and data, opcodes corresponds to the code portion and
operands corresponds to the data portion 5
Sample 8086 Assembly program

o Find the sum of 20H, 30H, 40H and 50H

mov ax, 20h ; Load 20h into AX


add ax, 30h ; Add 30h to AX
add ax, 40h ; Add 40h to AX
add ax, 50h ; Add 50h to AX AX now contains
the result (E0h)
o Machine code for the above program
B8 20 00 05 30 00 05 40 00 05 50 00
6
Assembly program Execution Flow

add.asm add.hex Load the hex file to Start processor


8086 assembler program
8086 main memory

7
Addressing modes

o Addressing modes are different ways processor accesses code


or data stored in registers and memory to perform operations
o 8086 supports far more varieties of addressing modes compared
to its predecessors
o Later x86 family of processors support additional addressing
modes
o 8086 addressing modes we will consider data addressing
modes and program addressing modes separately
o We will use MOV instruction to demonstrate different data
addressing modes
8
Data Addressing modes

o Data addressing modes are used to access data


o They are classified as
 Register addressing
 Immediate addressing
 Direct addressing
 Displacement addressing
 Register indirect addressing
 Base plus index addressing
 Register relative addressing
9
 Base relative plus index addressing
Register Addressing

o Copies one or more bytes from one register to another


MOV AX,BX
Copies 16-bit data from BX register to AX register

MOV AL,BL
Copies 8-bit data from BL register to AL register

MOV CH,AL
Copies 8-bit data from AL register to CH register

MOV AL,BX
Trying to move 16-bit data from BX to AL (8-bit register)
May be no syntax error but should not use 10
Register Addressing

o You can move data between general purpose registers and


general-purpose registers and segment registers but you cannot
move data between segment registers

MOV AX,CX
MOV between general purpose register

MOV CS,BX
MOV between general purpose and segment registers

MOV DS,CS
11
MOV between segment registers is illegal
Immediate Addressing

o Transfers an immediate data (a constant byte or a word) to a


register or memory

MOV AL,22
Copies data 22H to AL register (1 Byte data transfer)

MOV BX,49FE
Copies data 49FEH to BX register (2 Bytes (one word) data
transfer)

MOV CH,145
12
Error since CH (1 byte register) cannot store 145H (2 bytes)
Immediate Addressing

o When moving data to register, the size of data (1-byte or 2-bytes) to


copy assembler can understand from destination register size
MOV AL,20;One byte transfer since AL is 1 byte
MOV AX,20;Two bytes transfer since AX is 2 bytes
o But when immediate data is moved to a memory location, assembler
cannot decide the data transfer size since using 8086 both 1-byte
data and 2-byte data can be transferred to memory

o Eg: We need to store 0035H in main memory starting from address


2000H (0035H will be stored as 35H in 2000H and 00H in 2001H
since Intel follows little endian architecture) 13
Immediate Addressing

o But if you need to store 35H in memory address 2000H, the


instruction will look exactly same

How to distinguish between them?

o We need to add this information to the instruction

MOV BYTE PTR [2000],35 ;move byte (1 byte)


MOV WORD PTR [2000],35 ;move word (2 bytes)
MOV DWORD PTR [2000],35;move dword (4 bytes)
14
Immediate Addressing
MOV WORD PTR [2000],35 ;move byte (1 byte)
Address
2000 35
2001 00
Latch
2002 XX
2003 XX
Memory

MOV BYTE PTR [2000],35 ;move byte (1 byte)


Address
2000 35
2001 XX
Latch
2002 XX
2003 XX 15

Memory
Immediate Addressing

MOV WORD PTR [2000],35 ;move word


MOV BYTE PTR [2000],35 ;move byte
o The machine codes (binary) for MOV WORD PTR and MOV BYTE
PTR are different
o That is how the assembler understands which machine code to be
used during assembling
o You cannot move immediate data to segment registers

MOV CS,800 ;illegal


16
Direct Addressing

o Moves a byte or word between memory and AL or AX register


o The address is directly specified in the instruction

MOV AX,[23FE]
o Copies 16-bit data (word) from address 23FE to AX register. Since
16-bit data, data in 23FE will get copied to AL register and 23FF to
AH

MOV [12FC],AL
o Copies 8-bit data from AL register to address DS:12FC
17
Displacement Addressing

o Moves a byte or word between memory and register


o Looks exactly same as direct addressing in assembly, but instead of AX
or AL any other register is used

MOV CX,[23FE]
o Copies 16-bit data (word) from address 23FE to CX register. Since 16-
bit data, data in 23FE will get copied to CL register and 23FF to CH

o Difference between direct and displacement addressing is in instruction


size
o Direct addressing takes 2 bytes in machine code whereas displacement18
takes 3 bytes
Displacement Addressing

o There is no support for memory-to-memory data transfer in 8086

MOV [34F8],[23FE] ;illegal

o First copy from memory to register and then register to memory


MOV AL,[23FE]
MOV [34F8],AL

19
Register Indirect Addressing

o Data is accessed with the help of a pointer register


o Memory address of data is stored in a pointer register, then using
that pointer data is accessed
o We can use BP, BX, DI and SI as pointer registers
o Eg: Assume you need to copy data from address 1000 and 1001 to
AX register
o We can use BX register as pointer
MOV BX,1000 ;store address in pointer
MOV AX,[BX] ;using pointer, access data

20
Register Indirect Addressing

o Instructions such as
MOV [DI],10
also creates ambiguity regarding size of data (whether 1-byte or 2-
bytes)
o Will have to use size specification
MOV byte ptr [DI],10 ;move 1 byte
MOV word ptr [DI],10 ;move 1 word
MOV dword ptr [DI],10 ;move 1 dword
o The qualifiers byte ptr, word ptr etc. are assembler directives,
which help assembler to choose the proper machine code
21
Base Plus Index Addressing

o Similar to register indirect addressing, but uses two registers (one


base and one index) to calculate the physical address
o Can use BP or BX as base registers
o Can use SI or DI as index registers
MOV DX,[BX+SI]
o Memory offset address here = BX+SI
o This style of addressing is very helpful in accessing array elements
by storing the array start address in a base address and using an
index register to specify index number of array element
22
Register Relative Addressing

o Like base+index, but instead of specifying the offset in a register, it is


specified as a 16-bit signed number

o BP,BX,SI or DI can be used to store the base address


MOV AX,[BP+100]
MOV BL,[BX-200]
MOV CX,[SI+2000]
MOV CL,[DI+305]

o Displacement value between -32768 (8000H) to +32767 (7FFFH)


23
Base Relative Plus Index Addressing

o Combination of base+index and register relative


o Address is specified by a base register (BX or BP), index register (SI
or DI) and a 16-bit signed constant displacement

MOV AX,[BX+SI+100]

o Here memory offset address will be BX+SI+100

24
Thank you
any questions

25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy