1 / 18

Microcontroller Fundamentals & Programming

Microcontroller Fundamentals & Programming. Addressing Modes. Addressing Modes. Addressing Modes define the different methods, instructions obtain data required for its execution. What are 68hc11 instructions ? Examples: LDAA #$55 LDAA $20,X LDAB $2000

soyala
Download Presentation

Microcontroller Fundamentals & Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microcontroller Fundamentals & Programming Addressing Modes

  2. Addressing Modes • Addressing Modesdefine the different methods, instructions obtain data required for its execution. • What are 68hc11 instructions ? • Examples: LDAA #$55 LDAA $20,X LDAB $2000 BRA BEGIN Some 68HC11 instructions.

  3. Types of Addressing Modes • The 68HC11 has 6addressing modes: • Direct • Extended • Index • Immediate • Inherent • Relative

  4. Direct Addressing Mode • Access data from memory $00 to $FF. • Instruction makes up of 2 bytes machine code. • (one byte of Op-code ,one byte of Operand Address). • Example: • LDAA $30 ; contents of memory ($0030) ; load into ACCA Op-code Operand Address

  5. CPU ACCA $FF Example LDAA $30 ; contents of memory ($0030) ; load into ACCA. Before execution After execution Memory Memory CPU B6 $002F 55$0030 3C $0031 B6 $002F 55 $0030 3C $0031 ACCA $55

  6. Op-code Operand (2-bytes) Extended Addressing Mode • Almost similar to Direct Addressing Mode. • Accessed data from memory ($0100) to ($FFFF). • Instruction consists 3 bytes of machine code. • ( one opcode and two operands = 3 bytes ). Example: LDAA $8830 ; contents of memory ($8830) ; loaded into ACCA

  7. CPU ACCA $55 Example LDAA $8830 ; contents of memory ($8830) ; load into ACCA After execution Before execution Memory Memory CPU B6 $882F 99$8830 3C $8831 B6 $882F 99 $8830 3C $8831 ACCA $99

  8. Index Addressing Mode • The effective memory address: • = afixed, 8-bit, unsigned offset number + • contents of Index register (IX or IY). • Instruction accessed memory ($0000) to ($FFFF). • The offset number range from $00 to $FF. Example LDAA $31 , X ; load contents of memory ($31+IX) ; into ACCA + effective address = offset number Index register

  9. Memory Memory CPU CPU ACCA $FF ACCA$55 69 $9030 55 $9031 $9032 69 $9030 55 $9031 $9032 IX $9000 IX $9000 Example LDAA $31,X ; if IX = $9000 then, contents of ; memory ($9031) load into ACCA. Before execution After execution

  10. Immediate Addressing Mode • Instruction contains immediate value to load into register. • Immediate value must be preceded by “#” character. • The immediate value = operand of instruction =operand data of instruction. Example: LDAA ; hex value $69 loaded into ACCA. LDY ; hex value $1234 loaded into IY. #$69 #$1234

  11. Example LDAA #$69 ; load value of $69 into ACCA Before execution After execution Memory Memory CPU CPU ACCA $FF ACCA$69

  12. Example: a) TAB ;transfer contents of ACCA to ACCB. b) DEX ; IX = subtract contents of IX by one. ; IX =(IX) - $01 c) DAA ; Decimal Adjust ACCA (BCD) Inherent Addressing Mode • Only, opcode used and no operand required. • The operation involves the CPU registers. • The opcode will specify the registers involved.

  13. Relative Addressing Mode • Used by branch instructions. (BRA, BHI … ) • The offset ($dd) ranges from -12810 to +12710 . Example: BEQ $dd ; if Z flag =“0”, ; program executes the next instruction. ; if Z flag =“1”, ; program branches & executes • ; instruction pointed by (PC + $dd).

  14. AddressMachine CodeMnemonics $8000 4F CLRA $8001 27 20 BEQ $20 $8003 B7 C0 00 STAA $C000 - - - - - - - - - - $8023 86 29 LDAA #$29 - - - - - PC PC Example • Executing BEQ $20 Relative branch to ($8023). • see next page for calculation.

  15. Example (contd) • Address ($8001) contains BEQ = Current address. • Address ($8023 = PC + Offset) = Destination address. • The value $20 in (BEQ $20) = Offset. Equation: Destination = PC + Offset. Address = $8003 + $20 = $8023 (Ans.)

  16. Summary of 6 Addressing Modes • Addressing • S/NModesMnemonicsComments • Direct LDAA $55 ; memory address ; is 1 byte • Extended LDAB $8050 ; memory address ; is 2 bytes • Index LDAA $20,X ; index register is ; part of address

  17. Summary of 6 Addressing Modes • Addressing • S/NModesMnemonicsComments • Immediate LDAB #$55 ; data $55 is ; loaded into ACCB • Inherent RTS ; only opcode and ; no data • Relative BRA BEGIN ; branch to label ; “BEGIN”

  18. Thank You

More Related