Chapter 3 Addressing Modes

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
Department of Computer Science and Software Engineering
Chapter Four–80x86 Instruction Set Principles of Microcomputers 2015年5月17日 2015年5月17日 2015年5月17日 2015年5月17日 2015年5月17日 2015年5月17日 1 Chapter four 80x86.
6-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL Intel 8088 Addressing modes.
Using the Assembler Chapter 4 Operators and Expressions
Irvine, Kip R. Assembly Language For Intel-Based Computers TYPE and SIZE Operators TYPE –returns the size, in bytes of a single element of a data label.
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.
Handout 2 Digital System Engineering (EE-390)
Stack Memory H H FFFFF H FFFFE H SS 0105 SP 0008 TOS BOS BOS = FFFF = 1104F H H 1104F H.
Addressing modes – 1 The way in which an operand is specified is called the Address Mode.
The 8086 Assembly Programming Data Allocation & Addressing Modes
Lecture 2 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
1 Lecture 4: Data Transfer, Addressing, and Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
Microprocessor Systems Design I
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2014 Lecture 4: x86 memory.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
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.
CSC 221 Computer Organization and Assembly Language
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 7: More on Addressing Modes, Structures, and Stack Constantine D. Polychronopoulos Professor, ECE.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
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.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
(-133)*33+44* *33+44*14 Input device memory calculator Output device controller Control bus data bus memory.
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.
Chapter 2 The Microprocessor Architecture Microprocessors prepared by Dr. Mohamed A. Shohla.
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.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
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.
1 Using the Assembler Chapter – 4(A). 2 Exchanging Two Variables title Exchange Two Variables (Exchange.asm).model small.stack 100h.data value1 db 0Ah.
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.
Instruction set Architecture
Presentation on Real Mode Memory Addressing
Microprocessor Systems Design I
Microprocessor Systems Design I
ADDRESSING MODES.
16.317: Microprocessor System Design I
Microprocessor Systems Design I
Chapter 4 Data Movement Instructions
EEM336 Microprocessors Laboratory Orientation
Assembly IA-32.
ADDRESSING MODES.
Assembly Lang. – Intel 8086 Addressing modes – 1
Chapter 3 Addressing Modes
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
3.6 Data transfer Instructions
8086 Registers Module M14.2 Sections 9.2, 10.1.
32-bit instruction mode(80386-Pentium 4 only)
(Array and Addressing Modes)
Chapter 3: Addressing Modes
The Microprocessor & Its Architecture
(Array and Addressing Modes)
CNET 315 Microprocessor & Assembly Language
Computer Architecture CST 250
Addressing Modes MOV AX,BX Destination Source Data-Addressing Modes.
(Array and Addressing Modes)
Presentation transcript:

Chapter 3 Addressing Modes Microprocessors Chapter 3 Addressing Modes prepared by Dr. Mohamed A. Shohla

Chapter Overview Register Addressing Immediate Addressing Direct Data Addressing Register Indirect Addressing Base-Plus-lndex Addressing Register Relative Addressing Base Relative-Plus-lndex Addressing

Data-Addressing Modes Register addressing Transfers a copy of a byte or word from the source register or memory location to the destination register or memory location. Immediate addressing Transfers the source-immediate byte or word of data into the destination register or memory location. Direct addressing Moves a byte or word between a memory location and a register. The instruction set does not support a memory-to-memory transfer, except for the MOVS instruction. Register indirect addressing Transfers a byte or word between a register and a memory location addressed by an index or base register. The index and base registers are BP, BX, DI, and SI. Base-plus-index addressing Transfers a byte or word between a register and the memory location addressed by a base register (BP or BX) plus an index register (DI or SI). Register relative addressing Moves a byte or word between a register and the memory location addressed by an index or base register plus a displacement. 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. Scaled-index addressing Is available only in the 80386 through the Pentium 4 microprocessor. The second register of a pair of registers is modified by the scale factor of 2X, 4X, or 8X to generate the operand memory address.

The MOV instruction

Register Addressing Examples of the register-addressed instructions. Register addressing is the most common form of data addressing and, once the register names are learned, is the easiest to apply. Examples of the register-addressed instructions.

Register Addressing Example : MOV BX, CX The effect of executing the MOV BX, CX instruction at the point just before the BX register changes. Note that only the rightmost 16 bits of register EBX change.

Immediate Addressing Examples of the immediate-addressed instructions. The term immediate implies that the data immediately follow the hexadecimal opcode in the memory. Also note that immediate data are con­stant data, while the data transferred from a register are variable data. Examples of the immediate-addressed instructions.

Immediate Addressing Example: MOV EAX, 13456H The operation of the MOV EAX,13456H in­struction. This instruction copies the immediate data (13456H) into EAX.

Direct Data Addressing Direct addressing with a MOV instruction transfers data between a memory location, located within the data segment, and the AL (8-bit), AX (16-bit), or EAX (32-bit) reg­ister. Examples of the Direct addressed instructions.

Direct Addressing Example : MOV AL, [1234H] The operation of the MOV AL,[1234H] when DS = 1000H.

Example .MODEL SMALL ; select SMALL model .DATA ; indicate start of DATA segment DATA1 DB 10H ; place 10H in DATA1 DATA2 DB 0 ; place 0 in DATA2 DATA3 DW 0 ; place 0 in DATA3 DATA4 DW 0AAAAH ; place AAAAH in DATA4 .CODE ; indicate start of CODE segment .STARTUP ; indicate start of program MOV AL, DATA1 ; copy DATA1 to AL MOV AH, DATA2 ; copy DATA2 to AH MOV DATA3, AX ; save AX at DATA3 MOV BX, DATA4 ; load BX with DATA4 .EXIT ; exit to DOS END ; end file

Register Indirect Addressing Register indirect addressing allows data to be addressed at any memory location through an offset address held in any of the following registers: BP, BX, DI, and SI. Examples of the Register indirect addressed instructions.

Register indirect Addressing Example : MOV AX, [BX] The operation of the MOV AX,[BX] instruction when BX = 1000H and DS = 0100H. Note that this instruction is shown after the contents of memory are transferred to AX.

Base-Plus-lndex Addressing Base-plus-index addressing is similar to indirect addressing because it indirectly addresses memory data. In the 8086 through the 80286, this type of addressing uses one base register (BP or BX), and one index register (DI or SI) to indirectly address memory. Examples of the Base-Plus-Index addressed instructions.

Base-Plus-lndex Addressing Example : MOV DX, [BX + DI] An example showing how the base-plus-index addressing mode functions for the MOV DX,[BX+DI] instruction. Notice that memory address 02010H is accessed because DS = 0100H, BX = 100H, and DI = 0010H.

Example .MODEL SMALL ; select SMALL model .DATA ; start of DATA segment ARRAY DB 16 DUP (?) ; setup ARRAY DB 29H ; sample data at element 10H DB 30 DUP (?) .CODE ; start of CODE segment .STARTUP ; start of program MOV BX, OFFSET ARRAY ; address ARRAY MOV DI, 10H ; address element 10H MOV AL, [BX+DI] ; get element 10H MOV DI, 20H ; address element 20H MOV [BX+DI], AL ; save in element 20H .EXIT ; exit to DOS END ; end of file

Register Relative Addressing Register relative addressing is similar to base-plus-index addressing and displacement address­ing. In register relative addressing, the data in a segment of memory are addressed by adding the displacement to the contents of a base or an index register (BP, BX, Dl, or SI). Examples of the register Relative addressed instructions.

Register Relative Addressing MOV AX, [BX + 1000H] The operation of the MOV AX,[BX+1000H] instruction, when BX = 0100H and DS = 0200H.

Register relative addressing used to address an element of ARRAY. The displacement addresses the start of ARRAY, and Dl accesses an element.

Example .MODEL SMALL ; select SMALL model .DATA ; start of DATA segment ARRAY DB 16 DUP (?) ; setup ARRAY 00 ] DB 29H ; sample data at element 10H DB 30 DUP (?) .CODE ; start of CODE segment .STARTUP ; start of program MOV DI, 10H ; address element 10H MOV AL, ARRAY[DI] ; get element 10H MOV DI, 20H ; address element 20H MOV ARRAY[DI], AL ; save in element 20H .EXIT ; exit to DOS END ; end of file

Base Relative-Plus-lndex Addressing Assembly Language Size Operation MOV DH, [BX+DI+20H] MOV AX, FILE[BX+DI] MOV LIST[BP+DI], CL 8-bits 16-bits Copies the byte contents of the data segment memory location addressed by the sum of BX, Dl, and 20H into DH. Copies the word contents of the data segment memory location addressed by the sum of FILE, BX, and Dl into AX. Copies CL into the stack segment memory location addressed by the sum of LIST, BP, and Dl

Base Relative-Plus-lndex Addressing MOV AX, [BX+SI+100H] An example of base relative-plus-index addressing using a MOV AX, [BX+SI+100H] instruction. Note: DS = 1000H.

Chapter 3 Questions and Answers

What do the following MOV instructions accomplish. (a) MOV. AX, BX What do the following MOV instructions accomplish? (a) MOV AX, BX (b) MOV BX, AX (c) MOV BL, CH (d) MOV ESP, EBP (e) MOV AX, CS Instruction Accomplish (a) MOV AX, BX Copy the contents of register BX into register AX (b) MOV BX, AX Copy the contents of register AX into register BX (c) MOVBL, CH Copy the contents of register CH into register BL (d) MOV ESP, EBP Copy the contents of register EBP into register ESP (e) MOV AX, CS Copy the contents of register CS into register AX

List the 8-bit , 16-bit, and 32-bit registers that are used for register addressing. AH, AL, BH, BL, CH, CL, DH, DL 16-bit AX, BX,CX, DX, SP, BP, DI, SI 32-bit EAX, EBX,ECX, EDX, ESP, EBP, EDI, ESI

Select an instruction for each of the following tasks: (a) copy EBX into EDX (b) copy BL into CL (c) copy SI into BX (d) copy DS into AX (e) copy AL into AH Task Instruction (a) copy EBX into EDX MOV EDX, EBX (b) copy BL into CL MOV CL, BL (c) copy SI into BX MOV BX, SI (d) copy DS into AX MOV AX, DS (e) copy AL into AH MOV AH, AL

Select an instruction for each of the following tasks: (a) move a 12H into AL (b) move a 123AH into AX (c) move a CDH into CL (d) move a 1000H into SI (e) move a 1200A2H into EBX Task Instruction (a) move a 12H into AL MOV AL, 12H (b) move a 123AH into AX MOV AX, 123H (c) move a CDH into CL MOV CL, CDH (d) move a 1000H into SI MOV SI, 1000H (e) move a 1200A2H into EBX MOV EBX, 1200A2H

Suppose that DS = 0200H, BX= 0300H, and DI = 400H Suppose that DS = 0200H, BX= 0300H, and DI = 400H. Determine the memory address ac­cessed by each of the following instructions, assuming real mode operation: (a) MOV AL, [1234H] (b) MOV EAX, [BX] (c) MOV [DI], AL Starting address of the segment (DS) 2000H + displacement (1234H) + 1234H Memory location address 3234H Starting address of the segment (DS) 2000H + displacement (BX) + 0300H Memory location address 2300H Starting address of the segment (DS) 2000H + displacement (DI) + 0400H Memory location address 2400H

Choose an instruction that requires BYTE PTR, WORD PTR, DWORD PTR. MOV BYTE PTR [DI], 33 WORD PTR MOV WORD PTR [DI], 33 DWORD PTR MOV DWORD PTR [DI], 33

Suppose that DS = 1000H, SS = 2000H, BP = 1000H, and DI = 0100H Suppose that DS = 1000H, SS = 2000H, BP = 1000H, and DI = 0100H. Determine the memory address accessed by each of the following instructions, assuming real mode operation: (a) MOV AL, [BP+DI] (b) MOV CX, [DI] (c) MOV EDX, [BP] (a) Starting address of the segment (SS) 20000H + Base (BP) + 1000H + Index (DI) + 0100H Memory location address 21100H (b) Starting address of the segment (DS) 10000H + displacement (DI) + 0100H 10100H (c) Starting address of the segment (SS) 21000H

Suppose that DS = 1200H, BX = 0100H, and SI = 0250H Suppose that DS = 1200H, BX = 0100H, and SI = 0250H. Determine the address accessed by each of the following instructions, assuming real mode operation: (a) MOV [100H], DL (b) MOV [SI+100H], EAX (c) MOV DL, [BX+100H] (a) Starting address of the segment (DS) 12000H + displacement (100H) + 100H Memory location address 12100H (b) Starting address of the segment (DS) + register SI (0250H) + 0250H + 100H 12350H (c) Starting address of the segment (SS) 20000H + register BX (0100H) + 0100H 20200H

Suppose that DS = 1100H, BX = 0200H, LIST = 0250H, and SI = 0500H, determine the ad­dress accessed by each of the following instructions, assuming real mode operation: (a) MOV LIST[SI], EDX (b) MOV CL, LIST[BX+SI] (c) MOV CH, [BX+SI] (a) Starting address of the segment (DS) 11000H + address of List (0250H) + 0250H + register SI (0500H) + 0500H Memory location address 11750H (b) Starting address of the segment (DS) + address of List (0250H) + register BX (0200H) + 0200H + register SI (0500H) 11950H (c) Starting address of the segment (DS) 11700H

Suppose that DS = 1300H, SS = 1400H, BP = 1500H, and SI = 0100H Suppose that DS = 1300H, SS = 1400H, BP = 1500H, and SI = 0100H. Determine the address accessed by each of the following instructions, assuming real mode operation: (a) MOV EAX, [BP+200H] (b) MOV AL, [BP+SI-200H] (a) Starting address of the segment (SS) 14000H + register BP (1500H) + 1500H + displacement (200H) + 200H Memory location address 15700H (b) Starting address of the segment (SS) + register BP (1500H) + register SI (0100H) + 0100H - displacement (200H) - 200H 15400H

Suppose that DS = 1300H, SS = 1400H, BP = 1500H, and SI = 0100H Suppose that DS = 1300H, SS = 1400H, BP = 1500H, and SI = 0100H. Determine the address accessed by each of the following instructions, assuming real mode operation: (a) MOV EAX, [BP+200H] (b) MOV AL, [BP+SI-200H] (a) Starting address of the segment (SS) 14000H + register BP (1500H) + 1500H + displacement (200H) + 200H Memory location address 15700H (b) Starting address of the segment (SS) + register BP (1500H) + register SI (0100H) + 0100H - displacement (200H) - 200H 15400H