COMP3221: Microprocessors and Embedded Systems

Slides:



Advertisements
Similar presentations
Instruction Set Design
Advertisements

Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Accessing Atmega32 SRAM data memory
CEG3420 Lec2.1 ©UCB Fall 1997 ISA Review CEG3420 Computer Design Lecture 2.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
Computer Organization and Architecture
Chapter 11 Instruction Sets
COMP3221: Microprocessors and Embedded Systems
COMP3221: Microprocessors and Embedded Systems--Lecture 7 1 COMP3221: Microprocessors and Embedded Systems Lecture 7: Arithmetic and logic Instructions.
COMP3221: Microprocessors and Embedded Systems--Lecture 7 1 COMP3221: Microprocessors and Embedded Systems Lecture 7: Arithmetic and logic Instructions.
LC-3 Computer LC-3 Instructions
COMP3221: Microprocessors and Embedded Systems--Lecture 8 1 COMP3221: Microprocessors and Embedded Systems Lecture 8: Program Control Instructions
Execution of an instruction
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.
Chapter 5 The LC-3 LC-3 Computer Architecture Memory Map
COMP3221: Microprocessors and Embedded Systems--Lecture 4 1 COMP3221: Microprocessors and Embedded Systems Lecture 4: Number Systems (II)
CIS429.S00: Lec7- 1 Instruction Set Architectures (cont) History Addressing Modes --> Types of Instructions --> Encoding Instructions --> DLX Instruction.
Microprocessors Introduction to RISC Mar 19th, 2002.
1 RISC Machines l RISC system »instruction –standard, fixed instruction format –single-cycle execution of most instructions –memory access is available.
Pentium Addressing Modes
Unit -II CPU Organization By- Mr. S. S. Hire. CPU organization.
COMP3221: Microprocessors and Embedded Systems--Lecture 9 1 COMP3221: Microprocessors and Embedded Systems Lecture 9: Data Transfer Instructions
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)
Overview of Microprocessors
Architecture of the MSP430 Processor. Central Processing Unit Program Counter (PC) - Contains the address of the next instruction to be executed. The.
Part II: Addressing Modes
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
Parul Polytechnic Institute Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name.
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
Computer Architecture and the Fetch-Execute Cycle
ECE 265 – LECTURE 8 The M68HC11 Basic Instruction Set The remaining instructions 10/20/ ECE265.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
The LC-3. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5-2 Instruction Set Architecture ISA = All of the.
Execution of an instruction
26-Nov-15 (1) CSC Computer Organization Lecture 6: Pentium IA-32.
9/20/6Lecture 2 - Prog Model Architecture, Data Types and Addressing Modes.
Computer Architecture Lecture 03 Fasih ur Rehman.
Lecture Set 4 Programming the 8051.
©These slides may be freely used, distributed, and incorporated into other works. 1 Addressing Modes For speed… we want fixed-size instructions, and they.
Computer Organization Rabie A. Ramadan Lecture 3.
Instruction Sets: Addressing modes and Formats Group #4  Eloy Reyes  Rafael Arevalo  Julio Hernandez  Humood Aljassar Computer Design EEL 4709c Prof:
COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE Lecture 21 & 22 Processor Organization Register Organization Course Instructor: Engr. Aisha Danish.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
“ INSTRUCTIONS SET OF AVR MICROCONTROLLER ” SIGMA INSTITUTE OF ENGINEERING Prepared By: SR.NO NAME OF STUDENT ENROLLMENT 1 Abhishek Lakhara
Displacement (Indexed) Stack
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
COMP2121: Microprocessors and Interfacing
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
Microcomputer Programming
ADDRESSING MODES.
A Closer Look at Instruction Set Architectures: Expanding Opcodes
William Stallings Computer Organization and Architecture 8th Edition
EECE-276 Fall 2003 Microprocessors & Microcontrollers II
Addressing Modes Register Direct, with 1 and 2 registers I/O Direct
1 Overview of Microprocessors A. Parveen. 2 Lecture overview Introduction to microprocessors Instruction set architecture Typical commercial microprocessors.
Computer Architecture and the Fetch-Execute Cycle
68000 Architecture, Data Types and Addressing Modes
COMP3221: Microprocessors and Embedded Systems
Introduction to Micro Controllers & Embedded System Design
Introduction to Microprocessor Programming
COMP3221: Microprocessors and Embedded Systems
CS501 Advanced Computer Architecture
Presentation transcript:

COMP3221: Microprocessors and Embedded Systems Lecture 6: Addressing Modes http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2004 COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Overview Addressing Modes AVR Instruction Examples COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Operands Instructions need to specify where to get operands from Some possibilities Value is in instruction Value is in a register Register number is in the instruction Value is in memory address is in instruction address is in a register register number is in the instruction address is register value plus some offset offset is in the instruction (or in a register) These are called addressing modes COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Immediate Addressing Not really an addressing mode – since there is no address Instruction doesn’t have address of operand – it has the value itself i.e. the operand is immediately available Limits to the size of the operand you can fit in an instruction (especially in RISC machines which have instruction word size = data word size) COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Immediate Addressing Examples AVR Pentium SUBI 0101 KKKK Rd ADWI 1001 0110 KK Rd KKKK 1011 1 011 KKKK mov ebx, KKKK COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Direct Addressing Address of the memory operand is in the instruction Useful for global variables (accessible from all subroutines) AVR Datasheet calls this “Data Direct Addressing” and I/O Direct Addressing. COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Direct Addressing Examples AVR 1001001 Rd 0000 kkkk kkkk kkkk STS Pentium 1010 0001 kkkk kkkk kkkk mov eax,[kk] COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Register Direct Addressing Register numbers are contained in the instruction Data in the registers. Fastest mode and most common mode in RISC Example: ADD AVR 0000 11 r ddddd r r r r Pentium 0000 0000 11 r r r ddd 10 rd 00 0000 rs1 - rs2 Sparc COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Register Indirect Addressing Register number in instruction, as with register addressing However, contents of the register is used to address memory the register is used as a pointer AVR datasheet calls this “Data Indirect” addressing COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Register Indirect Addressing Example AVR LDD Rd, Y 1000000 ddddd 1000 Operation: Rd(Y) Y: r29: r28 COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Indexed Addressing Reference memory at a known offset from a register Two main uses: Register holds address of object; fixed offset indexes into the object (structure, array, etc) Address of object is constant; register has index into the object AVR datasheet calls this “Data Indirect with Displacement” addressing (fixed offset, not in register) COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Indexed Addressing Examples AVR (data indirect with displacement) Only 6 bit displacement (q bits) Only Y or Z index registers determined by this bit Operation: Rd  (Y + q) LDD Rd, Y+q 10 q qq ddddd 1 qqq COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Auto Increment Some architectures, allow modification of the index register as a side effect of the addressing mode Usually add or subtract a small constant, often equal to the operand size Could happen before or after the index register is used in the address calculation Most common are post increment and pre decrement AVR supports these “Data Indirect with Pre-decrement” “Data Indrect with Post-increment” COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Auto Increment Examples AVR LDD Rd, -Y 1001000 ddddd 1010 Operation: Y  Y–1 Rd  (Y) LDD Rd, Y+ Operation: Rd  (Y) Y  Y+1 1001000 ddddd 1001 COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Code Memory Constant Addressing AVR has separate data and instruction memories Sometimes need to get data constants out of instruction memory (flash memory) Special instruction provided to do this (LPM) LPM Rd, Z 1001000 ddddd 0100 Operation: Rd  (Z) Load a byte at the address contained in register Z (r30: r29) COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Branch Instructions Specify where in the program to go next (i.e. change the program counter rather than just increment) program flow is no longer linear Types of Branch Instructions Unconditional – always do it Conditional – do it if some condition is satisfied (e.g. check status register) Jumps – no return Subroutines (function calls) – can return COMP3221: Microprocessors and Embedded Systems--Lecture 6

COMP3221: Microprocessors and Embedded Systems--Lecture 6 Branch Instruction Addressing Modes Direct addressing Address to jump to included in the instruction Not every AVR device support this (JMP and CALL instructions) Indirect addressing Address to jump to is in a register AVR examples: IJMP, ICALL Program Counter Relative addressing AVR calls this “Relative Program Memory” addressing Add a constant value to the Program Counter AVR examples: RJMP, RCALL, conditional branch instructions… COMP3221: Microprocessors and Embedded Systems--Lecture 6

Branch Instruction Addressing Modes: AVR Examples JMP k Operation: PC  k (0 k  4M) 1001 010 kkkkk 110 k kkkk kkkk kkkk IJMP Operation: PC  Z 1001 0100 0000 1001 COMP3221: Microprocessors and Embedded Systems--Lecture 6

Branch Instruction Addressing Modes: AVR Examples BRGE k (signed) Operation: If Rd  Rr then PC  PC+k+1 else PC  PC+1 Operand: -64  k  +63 111101 kkkkkkk 100 COMP3221: Microprocessors and Embedded Systems--Lecture 6