Faculty of Computer Science © 2006 CMPUT 229 Addressing Modes Where to load from/store to.

Slides:



Advertisements
Similar presentations
Target Code Generation
Advertisements

There are two types of addressing schemes:
SUPPLEMENTARY CHAPTER 2 Instruction Addressing Modes
Machine Independent Assembler Features
Execution of an instruction
Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions.
The Structure of the CPU
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
Faculty of Computer Science © 2006 CMPUT 229 Accelerating Performance The RISC Revolution.
Chap 4 & 5 LC-3 Computer LC-3 Instructions Chap 4 Homework – due Monday October 27 Chap 5 Homework – due Wednesday October 29 Project 2 Designs (Working.
COMP3221: Microprocessors and Embedded Systems
Machine Dependent Assembler Features
Chapters 4 & 5: LC-3 Computer Architecture Machine Instructions Assembly language Programming in Machine and Assembly Language.
Chapter 11 Instruction Sets: Addressing Modes and Formats HW: 11.4, 5, 13, 16 (Due 11/15)
Faculty of Computer Science © 2006 CMPUT 229 Special-Purpose Codes Binary, BCD, Hamming, Gray, EDC, ECC.
Part II: Addressing Modes
MICRO-CONTROLLER MOTOROLA HCS12 Addressing Modes Mechatronics Department Faculty of Engineering Ain Shams Univeristy.
Processor Organization and Architecture Module III.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
Memory and Addressing How and Where Information is Stored.
Chapter 5 The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Data Movement Instructions Load --
Execution of an instruction
Faculty of Computer Science © 2006 CMPUT 229 Assembly Language Programming Control Flow, Endianess and Registers.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
Addressing Modes1 Addressing modes are concerned with how the CPU accesses the operands used by its instructions.
ECEG-3202 Computer Architecture and Organization Chapter 6 Instruction Sets: Addressing Modes and Formats.
©These slides may be freely used, distributed, and incorporated into other works. 1 Addressing Modes For speed… we want fixed-size instructions, and they.
INTRODUCTION Programming – process of composing several instructions to perform certain tasks. Program – product of programming which contains several.
Computer Organization Rabie A. Ramadan Lecture 3.
G.Umamaheswari Lect/IT R.M.D.EC system software
Elements of Datapath for the fetch and increment The first element we need: a memory unit to store the instructions of a program and supply instructions.
Computer Organization Instructions Language of The Computer (MIPS) 2.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic4: Procedures José Nelson Amaral.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Computer Architecture
Displacement (Indexed) Stack
Machine dependent Assembler Features
Immediate Addressing Mode
William Stallings Computer Organization and Architecture 8th Edition
Computer Organization and Assembly Language (COAL)
Design of the Control Unit for Single-Cycle Instruction Execution
Microprocessor and Assembly Language
EECE-276 Fall 2003 Microprocessors & Microcontrollers II
The fetch-execute cycle
THE sic mACHINE CSCI/CMPE 3334 David Egle.
Introduction to Micro Controllers & Embedded System Design Background to Module4 Department of Electrical & Computer Engineering Missouri University.
Computer Programming Machine and Assembly.
(Array and Addressing Modes)
Addressing Modes Immediate #<data> or Imm
ECEG-3202 Computer Architecture and Organization
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
Computer Architecture and the Fetch-Execute Cycle
Under Address Modes Source: under
68000 Architecture, Data Types and Addressing Modes
Introduction to Micro Controllers & Embedded System Design
(Array and Addressing Modes)
Computer Architecture
Stack Relative Deferred (sf) Indexed (x) Stack Indexed (sx)
CNET 315 Microprocessor & Assembly Language
Under Address Modes Source: under
CPU has 6 special locations called registers
Machine Independent Assembler Features
MIPS e pipelining Tecniche di base.
Instruction Set Summary
Machine Independent Assembler Features
Target Code Generation
William Stallings Computer Organization and Architecture 8 th Edition Chapter 11 Instruction Sets: Addressing Modes and Formats.
Copyright © 2013 Elsevier Inc. All rights reserved.
INSTRUCTION SET DESIGN
(Array and Addressing Modes)
Presentation transcript:

Faculty of Computer Science © 2006 CMPUT 229 Addressing Modes Where to load from/store to

© 2006 Department of Computing Science CMPUT 229 Immediate and Absolute Addressing  Immediate Addressing The value of the operand is contained in the instruction itself: MOVE#1234, D0[D0]  1234 ADD#1234, D0[D0]  [D0] Used to handle constants –Value must be known when the program is written  Absolute Addressing The address that contain the operand is part of the instruction MOVE1234, D0[D0]  [1234] ADD1234, D0[D0]  [D0] + [1234] Slower than immediate addressing (requires an additional memory access) Value can change after the program is written Clements, pp. 249

© 2006 Department of Computing Science CMPUT 229 Address-Register Indirect Addressing –The location of the value is in a pointer stored in an address register: ADD.B(A0), D0[D0]  [D0] + [[A0]] Clements, pp. 252 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Address-Register Indirect Addressing with Displacement –A constant is added to the value in an address register to determine the memory location of the operand. MOVE4(A0), D0[D0]  [[A0]+4] Clements, pp. 252 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Postincrementing and Predecrementing  Automatically increments/decrements the address register MOVE.B(A0)+, D0[D0]  [[A0]]; [A0]  [A0]+1 MOVE.W-(A2), (A3)+[A2]  [A2]-2; [[A3]]  [[A2]]; [A3]  [A3]+2 Clements, pp. 253 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Postincrementing and Predecrementing Clements, pp. 253 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Indexed Addressing  The address is given by two registers and a constant displacement MOVE.bOffset(A0, D0), D1[D1]  [[A0]+[D0]+Offset] Clements, pp. 258 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Indexed addressing (example)  PROBLEM: DIARY is a data structure divided into weeks and days. The week is in D0 and the position of a day within a week is given by a constant. Write a program that accesses the entry for Tuesday of a given week. –The address of this location is given by EntryAddress = DIARY + (WEEK-1)  7+TUESDAY

© 2006 Department of Computing Science CMPUT 229 Indexed addressing (example solution) SUNDAYEQU0 MONDAYEQU1 TUESDAYEQU2 WEDNESDAYEQU3 ….. LEADIARY, A0A0 points to the begin of the data structure MOVE.LWEEK, D0D0 contains the week number SUB.L#1, D0D0  WEEK - 1 MULU#7, D0D0  (WEEK - 1)  7 MOVE.BTUESDAY(A0,D0), D1Access the required entry EntryAddress = DIARY + (WEEK-1)  7+TUESDAY Clements, pp. 259

© 2006 Department of Computing Science CMPUT 229 Relative Address  Same as the indirect addressing, but the register used in the Program Counter (PC). –Makes possible to relocate programs without changing absolute addresses MOVEd16(PC), D0[D0]  [[PC] + d16] Clements, pp. 259

© 2006 Department of Computing Science CMPUT 229 Relative Address Clements, pp. 259 COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

© 2006 Department of Computing Science CMPUT 229 Relative Branching  The target address of most branches are also expressed relative to the current value of the PC

© 2006 Department of Computing Science CMPUT 229 Outer Product  Given two vectors, the outer product of these two vectors is defined as follows

© 2006 Department of Computing Science CMPUT 229 Exercise #2  Write a code whose inputs are in memory at the following addresses: $8000: word containing the length of vector u; $8002: long word with the address of the first position of u; $8006: word containing the length of vector v; $8008: long word with the address of the first position of v; $800C: long word with the address of the first position of matrix A;  The program has to compute the values in matrix A, where A is the outer product of u and v: –A = u  v –A must be stored on a row-first order.

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no Done yes A = u  v

© 2006 Department of Computing Science CMPUT 229 RTL Sketch A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A  Write a code whose inputs are in memory at the following addresses: $8000: word containing the length of vector u; $8002: long word with the address of the first position of u; $8006: word containing the length of vector v; $8008: long word with the address of the first position of v; $800C: long word with the address of the first position of matrix A; Address/Size Initialization

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch D3  W 0counter for vector u LoopUCMPD3,D1 BEQDone D4  W 0counter for vector v LoopVCMP D4,D2 BEQ nextU D4  W D4+1j  j+1 BRA LoopV nextU D3  W D3+1i  i+1 BRA LoopU Done  A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A Address/Size Initialization Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no yes Done

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch D3  W 0counter for vector u LoopUCMPD3,D1 BEQDone D4  W 0counter for vector v LoopVCMP D4,D2 BEQ nextU D4  W D4+1j  j+1 BRA LoopV nextU D3  W D3+1i  i+1 BRA LoopU Done  A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A Address/Size Initialization Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no yes Done

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch D3  W 0counter for vector u LoopUCMPD3,D1 BEQDone D4  W 0counter for vector v LoopVCMP D4,D2 BEQ nextU D4  W D4+1j  j+1 BRA LoopV nextU D3  W D3+1i  i+1 BRA LoopU Done  A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A Address/Size Initialization Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no yes Done

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch D3  W 0counter for vector u LoopUCMPD3,D1 BEQDone D4  W 0counter for vector v LoopVCMP D4,D2 BEQ nextU D4  W D4+1j  j+1 BRA LoopV nextU D3  W D3+1i  i+1 BRA LoopU Done  A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A Address/Size Initialization Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no yes Done

© 2006 Department of Computing Science CMPUT 229 Flow-Graph Sketch D3  W 0counter for vector u LoopUCMPD3,D1 BEQDone D4  W 0counter for vector v LoopVCMP D4,D2 BEQ nextU D4  W D4+1j  j+1 BRA LoopV nextU D3  W D3+1i  i+1 BRA LoopU Done  A0  L #$8000 D1  W (A0)+ length of vector u A1  L (A0)+ address of vector u D2  W (A0)+ length of vector v A2  L (A0)+ address of vector v A3  L (A0) address of matrix A Address/Size Initialization Addresses/Sizes Initialization i  0 counter for vector u i = size of u? j  0 counter for vector v j = size of v? A(i,j) = u(i)  v(j) j = j+1 i = i+1 yes no yes Done