Addressing Modes. Addressing Mode The data is referred as operand. The operands may be contained in registers, memory or I/O ports, within the instruction.

Slides:



Advertisements
Similar presentations
Chapter 2 (cont.) An Introduction to the 80x86 Microprocessor Family Objectives: The different addressing modes and instruction types available The usefulness.
Advertisements

There are two types of addressing schemes:
COMP 2003: Assembly Language and Digital Logic
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Department of Computer Science and Software Engineering
Chapter 3 Addressing Modes
Using the Assembler Chapter 4 Operators and Expressions
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 3 Addressing Modes Barry B. Brey.
Data Movement Instructions
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The 8086 Assembly Programming Data Allocation & Addressing Modes
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
KMUTT: S. Srakaew Instructions Can Be Divided into 3 Classes Data movement instructions  Move data from a memory location or register to another memory.
8-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 4 Data Movement Instructions by.
Microprocessor Systems Design I
80x86 Processor Architecture
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
Chapter 3: Addressing Modes. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel Microprocessors:
Lect 4: Instruction Set and Addressing Modes. 386 Instruction Set (3.4)  Basic Instruction Set : 8086/8088 instruction set  Extended Instruction Set.
Lecture 18 Last Lecture Today’s Topic Instruction formats
CSC 221 Computer Organization and Assembly Language
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
Dr. José M. Reyes Álamo 1.  The 80x86 memory addressing modes provide flexible access to memory, allowing you to easily access ◦ Variables ◦ Arrays ◦
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR1 Addressing Mode.
CSC 221 Computer Organization and Assembly Language
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Faculty of Engineering, Electrical Department,
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
ECE291 Computer Engineering II Lecture 3 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Microprocessors used in Personal Computers. The Memory Map of a Personal Computers Transient Program Area (TPA): Holds the operating system (interrupt.
MOV Instruction MOV destination,source  MOV AX,BX  MOV SUM,EAX  MOV EDX,ARRAY[EBX][ESI]  MOV CL,5  MOV DL,[BX]
Assembly Language Data Movement Instructions. MOV Instruction Move source operand to destination mov destination, source The source and destination are.
Internal Programming Architecture or Model
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Intel MP Organization. Registers - storage locations found inside the processor for temporary storage of data 1- Data Registers (16-bit) AX, BX, CX, DX.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
Type of addressing mode
Microprocessors CSE- 341 Dr. Jia Uddin Assistant Professor, CSE, BRAC University Dr. Jia Uddin, CSE, BRAC University.
Data Movement Instructions A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
Assembly language programming
Instruction set Architecture
Format of Assembly language
Introduction to 8086 Microprocessor
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Instruksi Set Prosesor 8088
ADDRESSING MODES.
16.317: Microprocessor System Design I
Microprocessor and Assembly Language
Chapter 4 Data Movement Instructions
Assembly IA-32.
ADDRESSING MODES.
University of Gujrat Department of Computer Science
Assembly Lang. – Intel 8086 Addressing modes – 1
Chapter 3 Addressing Modes
Microprocessor and Assembly Language
Subject Name: Microprocesor Subject Code: 10CS45
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
8086 Registers Module M14.2 Sections 9.2, 10.1.
32-bit instruction mode(80386-Pentium 4 only)
Chapter 3: Addressing Modes
CNET 315 Microprocessor & Assembly Language
Addressing Modes MOV AX,BX Destination Source Data-Addressing Modes.
Data Movement Instructions
The JUMP GROUP Unconditional Jump (JMP).
Presentation transcript:

Addressing Modes

Addressing Mode The data is referred as operand. The operands may be contained in registers, memory or I/O ports, within the instruction itself. To access these different types of operands, has to address memory or I/O device. The address of memory and I/O can be calculated in different ways, called as “Addressing Modes”

Data Addressing Modes Fig.3.1 illustrates the MOV instruction and defines the direction of data flow3.1 Fig.3.2 shows all possible data variations of the data-addressing modes using the MOV instruction3.2 Register adressing:MOV CX,DX or MOV ECX,EDX Immediate addressing: MOV AL,22H or MOV EAX, H Direct addressing:MOV CX,LIST

Data Addressing Modes (cont’d) Register Indirect Addressing: MOV AX,[BX] Indexed Addressing mode: MOV AX,[SI] Base-plus-index addressing: MOV [BX+DI], CL or MOV [EAX+EBX],CL Register relative addressing: MOV AX,[BX+4] or MOV AX,ARRAY[BX] Base relative-plus-index addressing: MOV AX,ARRAY[BX+DI] or MOV AX,[BX+DI+4] Scaled-index addressing: MOV EDX,[EAX+4*EBX]

Register Addressing It is the most common form and is the easiest to apply Microprocessor contains 8-bit, 16-bit, 32-bit registers –Never mix an 8-bit register with a 16-bit register, 16-bit register with a 32-bit register, etc., because this results in an error when assembled Table 3.1 shows many variations of register move instructions3.1 Fig.3.3 shows the operation of the MOV BC,CX instruction3.3

Register Addressing Example 3.1 shows a sequence of assembled instructions that copy various data between 8-, 16-, and 32-bit registers3.1

Immediate Addressing The term immediate implies that the data immediately follow the hexadecimal opcode in the memory –Immediate are constant data –The MOV immediate instruction transfers a copy of the immediate data into a register or a memory location Fig.3.4 shows the source data (sometimes preceded by #) overwrite the destination data3.4 –The instruction copies the 13456H into register AX

Register Addressing Example 3.2 shows various immeidate instructions in a short program that placess a 0000H into the 16-bit registers AX, BX, CX3.2

Direct Data Addressing There two basic forms of direct data addressing: –direct addressing, which applies to a MOV bet- ween a memory location and AL, AX or EAX –displacement addressing, which applies to almost any instruction in the instruction set Direct Addressing: MOV AL,DATA (Fig.3.5)3.5 –Table 3.3 lists the three direct addressed instruc- tion3.3 –A MOV instruction is 3-byte long instruction

Direct Data Addressing Displacement Addressing: MOV CL,DATA –almost identical with direct addressing except that the instruction is four bytes wide

Register Indirect Addressing It allows data to be addressed at any memory location through an offset address held in any of the following register: BP, BX, DI, and SI –MOV AX,[BX] Fig Data segment is used by default with register indirect addressing or any other addressing mode that uses BX, DI, or SI to address memory –If register BP addresses memory, the stack segment is used by default

Register Indirect Addressing Sometimes, indirect addressing requires spe- cifying the size of the data with the special assembler directive BYTE PTR, WORD PTR or DWORD PTR –These indicate the size of the memory data addressed by the memory pointer (PTR) Indirect addressing allows a program to refer to a tabular data located in the memory sys- tem (Fig.3.7 & Example 3.6)3.73.6

Indexed Addressing mode: Indexed Addressing mode: address is available in any index register SI,DI MOV AX,[SI]

Base-Plus-Index Addressing It indirectly addresses memory data –In , this use a base register (BP or BX, holds the beginning location of a memory array) and an index register (DI or SI, ) to indirectly addresses memory –In and above, this type of addressing allows the combination of any two 32-bit extended registers except #SP MOV DL, [EAX+EBX] Figure 3.8 shows the sample instruction of locating data with this scheme3.8

Base-Plus-Index Addressing (cont’d) The major use of this type of addressing is to address elements in a memory array –Fig.3.9 shows the use of BX (base) and DI (index) to access an element in an array of data)3.9 –Study Table 3.6 and Example 3.7 as well3.63.7

Register Relative Addressing In its, the data in a segment of memory are addressed by adding the displacement to the contents of a base or and index register (BP, BX, DI, or SI) –Fig.3.10 shows the operation of the MOV AX,[BX+ 1000H] instruction3.10 The displacement can be a number added to the register within the [ ], as in MOV AL,[DI+2], or it can be a displacement substracted from the register, as in MOV AL,[SI-1]

Register Relative Addressing (cont’d) It is possible to address array data with regis- ter relative addressing such as one does with base-plus-index addressing –See Fig.3.11 and study the example

Base Relative-Plus-Index Addressing This mode often addresses a two-dimension- al array of memory data It is the least-used addressing mode (i.e., too complex for frequent use in a program) Fig.3.12 shows how the instruction MOV AX, [BX+SI+100H].3.12 Addressing arrays with base relative-plus- index addressing the displacement addresses the file the base register addresses a record the index register addresses an element of a record Study Example 3.9 and Fig

Scaled-Index Addressing This type of addressing is unique to the Pentium Pro –It uses two 32-bit registers (a base register and an index register) to access the memory –The second register (index) is multiplied by a scaling factor (either 1X, 2X, 4X, or 8X) –MOV AX,[EDI+2*ECX] –See Example 3.10 and Table

Data Structures A data structure is used to specify how information is stored in a memory array; it can be quite useful with application that use arrays –The start of a structure is identified with the STRUC directive and ended with the ENDS –See Example When data are addressed in a structure, use the structure name and the field name to se- lect a field from the structure (Example 3.12)3.12

Program Memory Addressing Program memory-addressing modes (JMP and CALL) consist of three distinct forms: direct, relative, and indirect Direct Program Memory Addressing –The instruction store the address with the op- code

Program Memory-Addressing Modes Program memory-addressing modes (JMP and CALL) consist of three distinct forms: direct, relative, and indirect Direct Program Memory Addressing –The instructions store the address with the op- code –See Fig –It is called a far jump because it can jump to any memory location for the next instruction

Program Memory Addressing Modes (contd) Relative Program Memory Addressing –The term relative means “relative to the IP” –See Fig –JMP instruction is a one-byte instruction with a one-byte or two-byte displacement that adds to the instruction pointer –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

Program Memory Addressing Modes (contd) Indirect Program Memory Addressing –Table 3.10 lists some acceptable indirect program jump instructions, which can use any 16-bit register, any relative register, and any re- lative register with a displacement3.10 –If a 16-bit register holds the address of a JMP instruction, the jump is near –If a relative register holds the address, the jump is also considered an indirect jump –Fig.3.16 shows a jump table that is stored begin- ning at memory location TABLE3.16

Stack Memory-Addressing Modes Stack holds data temporarily and stores return addresses for procedures –The stack memory is LIFO memory –Use PUSH instruction to place data onto stack –Use POP instruction to remove data from stack The stack memory is maintained by two registers: SP or ESP, and SS –Study Fig –The PUSHA and POPA either push or pop all of the register, except the segment register, on the stack (see example 3.14)3.14