7_AVR Addressing Modes_ppt slides.pptx
Document Details
Uploaded by BuoyantFarce
Tags
Full Transcript
Lesson 7: AVR Program and Data Addressing Modes 1 Outlines: What are addressing modes AVR Instruction Format AVR Addressing Modes 2 What are Addressing Modes? Addressing modes of a machine are the various ways used...
Lesson 7: AVR Program and Data Addressing Modes 1 Outlines: What are addressing modes AVR Instruction Format AVR Addressing Modes 2 What are Addressing Modes? Addressing modes of a machine are the various ways used by its instructions to access various operands that are to be processed. Instructions of the same address mode have the same: – length, – binary syntax and number of fields, – Number of fetch & execution cycles, – … 3 Instruction Operands Operands of an AVR instruction could be in the following locations: – Register file – I/O Memory – SRAM, – Program memory (Flash) 4 AVR Instruction Format An AVR instruction is either one word (16 bits) or two words (32 bits). The first field of the instruction is always the “opcode”. According to the address mode, the instruction may have none, one or two additional fields called “operands”. 5 AVR Instruction Format Format1: Opcode – Always one word1(6 bit) Format2: – one word (16 bits) or two words (32 bits) Format3: – one word (16 bits) or two words (32 bits) 6 AVR Addressing Modes Register Direct, with 1 and 2 registers. Immediate Mode I/O Direct Data Direct Data Indirect – with pre-decrement – with post-increment Code Memory Addressing Prog. Memory Addressing Indirect Program Addressing Relative Program Addressing 7 Register Direct: 1 Register 8 Register Direct: 2 Registers 9 Register Direct: 2 Register pairs Example MOVW R17:R16, R1:R0 d = 1000 r = 0000 R16:1000 0 R1:0000 0 R17:1000 1 R2:0000 1 10 Immediate-Single Register Mode Example LDI R16, 78 ANI R31,$F0 11 Immediate-Register pair Mode Example ADIW R25:R24, 20 SBIW R31:R30, $F0 12 I/O Direct Example IN R25,$16 ;$16 is PIN B address OUT $18,R16 ;$18 is PORT B address 13 Data Direct LDS R16, 0x1000 STS store direct to data space LDSload direct from data space 14 Data Indirect Rd/Rr 15 Data Indirect w/ Displacement Rd/Rr q 16 Data Indirect: Pre-Decrement Rd/Rr 17 Data Indirect: Post-Increment Rd/Rr 18 Prog. Memory Addressing Rd/Rr Examples: LPM R3,Z Indirect Program Addressing Examples: IJMP ICALL Relative Program Addressing Examples: RJMP RCALL -2K ≤ k < 2K Assignment 7 AVR has 132 instructions (see instruction set summary). Try to find the address mode of each one. 23