Addressing Modes - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Addressing Modes

Description:

results: 0x86 0x55, will cause 0x55 to be loaded into accumulator A. ... How can we load a variable (RAM) location into the accumulator? ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 12
Provided by: ROTH8
Category:

less

Transcript and Presenter's Notes

Title: Addressing Modes


1
Addressing Modes
  • In order to provide programmers with flexibility
    and optimizations, microcontrollers offer a
    variety of addressing modes.
  • The HC11 offers six
  • Inherent
  • Immediate
  • Direct
  • Extended
  • Indexed X or Indexed Y
  • Relative

2
Definitions and Observations
  • Operation The abstract task the
    microcontroller is trying to accomplish
  • Opcode The machine code instruction
  • Operand Additional arguments for the operation
  • Many operation have more than one opcode. Why?
  • To select what addressing mode will be used
  • Example
  • LDAA immediate ? 0x86
  • LDAA direct ? 0x96
  • Most opcodes are 1 byte. Some are two. Why?
  • HC11 supports 308 unique operations/addressing
    modes combinations.
  • Some operations will have a pre-opcode
  • Example
  • LDAA ind,y ? 0x18 0xA6
  • Depending on the operation and addressing mode, a
    given opcode may fetch 0, 1, or 2 additional
    bytes from memory. What are the implications?
  • Some operations use more memory
  • Some operations take longer to complete
  • Is there a pattern to the operation / opcode
    assignments?

3
Inherent
  • Not really an addressing mode
  • Applies to operations that do not require an
    address or argument (operand) to operate
  • Examples
  • INX increment index register X
  • INY increment index register Y
  • DECA decrement accumulator A

4
Immediate
  • Operation (opcode) is followed by immediately by
    target of operation.
  • Definition of target varies by operation.
  • Example Load the next byte of memory into
    accumulator A.
  • logic M ? A
  • opcode 0x86
  • operand M the next byte in memory after the
    opcode
  • results 0x86 0x55, will cause 0x55 to be loaded
    into accumulator A.
  • Some operations may need two bytes of data.
  • LDD loads double accumulator with next two bytes
    of memory.

5
Reflect
  • Why do we need more addressing modes (let along
    six)?
  • Where is the 0x55 coming from in this case?
  • A fixed location
  • Likely in ROM
  • How can we load a variable (RAM) location into
    the accumulator?
  • We need the equivalent of pointers (from C)
  • instead of A M, we need A M, or load
    whatever value is in the memory location M is
    referring to.
  • Direct and Extended Addressing Modes
  • Operand becomes a pointer to, or the address
    of, the value to be loaded into the accumulator.

6
Direct
  • Operand of opcode is the 8-bit direct address
    from memory.
  • But HC11 has 16-bit address bus.
  • High address byte assumed
  • 0x0000 0x00FF (Page 0)
  • Example
  • Load whatever value is in address 0x0045 into the
    accumulator
  • 0x96 0x45

7
Extended
  • Two bytes are loaded which form a 16-bit address
  • Example Load whatever is in address 0x0003 into
    accumulator A.
  • 0xB6 0x00 0x03

8
Reflect
  • Why are there two versions that accomplish the
    exact same thing?
  • Performance
  • Page 0 RAM becomes a more efficient location to
    use for frequently used variables
  • Note, for LDAA
  • Direct version operates in 3 clocks, and consumes
    2 bytes
  • Extended version operates in four clocks and
    consumes 3 bytes.
  • 25 - 33 improvement
  • Page 0 RAM is a constrained resource
  • 256 bytes
  • Some may be used for other purposes.
  • Use it wisely

9
Indexed
  • Similar to direct and extended addressing
  • Use index register X or Y to form base address
  • Load an 8-bit (unsigned) offset from memory to
    add to base to get 16-bit address
  • Advantages
  • 16 bit address anywhere in memory
  • Only have to load 8-bit offset better
    performance
  • Example
  • Load contents of 0x1403 into accumulator A, index
    register X contains 0x1400.
  • 0xA6 0x03
  • Index Y operation have a pre-opcode
  • 0x18 0xA6 0x03
  • Avoid if possible
  • Index registers can be easily incremented and
    decremented. Fewer memory accesses to iterate
    memory.

10
Relative
  • Similar to indexed addressing
  • Only used for branches
  • Use current program counter (address following
    location of operand) to form base address
  • Load an 8-bit (signed) offset from memory to add
    to base to get 16-bit address
  • Limitations
  • Can only jump ahead 127 locations, or back 128
  • Example Loop forever, use BRA (Branch Always)
  • 0x20 0xFE
  • What if we want to branch further than Relative
    addressing allows?

11
Next Time
  • Demo, Instruction Set
Write a Comment
User Comments (0)
About PowerShow.com