Microcontroller Fundamentals Programming Data Movement Instructions Data Movement

  • Slides: 19
Download presentation
Microcontroller Fundamentals & Programming Data Movement Instructions

Microcontroller Fundamentals & Programming Data Movement Instructions

Data Movement Instructions § LOAD Instructions e. g. LDAA , LDAB , LDD ,

Data Movement Instructions § LOAD Instructions e. g. LDAA , LDAB , LDD , LDX , LDY § STORE Instructions e. g. STAA , STAB , STD , STX , STY § TRANSFER Instructions and e. g. TAB , TBA § EXCHANGE Instructions e. g. XGDX , XGDY 2

LOAD Instructions Load Instructions : Example: 68 HC 11 Memory LDAA , LDAB ,

LOAD Instructions Load Instructions : Example: 68 HC 11 Memory LDAA , LDAB , LDD , CPU LDX , LDY Regi sters Instructions load CPU 22 33 44 registers with values from memory or I/O. Data Flows I/O 3

Sample of Load Instructions (1) Instructions Addressing Modes LDAA #$30 IMM Description ; ACCA

Sample of Load Instructions (1) Instructions Addressing Modes LDAA #$30 IMM Description ; ACCA loaded with $30 (hex) CPU ACCA I/O $30 Data Flows 4

Sample of Load Instructions (2) Instructions Addressing Modes Description LDAA $30 DIR ; ACCA

Sample of Load Instructions (2) Instructions Addressing Modes Description LDAA $30 DIR ; ACCA loaded with contents ; from memory address $30 Memory Content CPU $22 ACCA $33 $44 Data Flows Memory Address $002 E $002 F $0030 5

Sample of Load Instructions (3) Instructions Addressing Modes LDD $9000 EXT CPU ACCA ACCB

Sample of Load Instructions (3) Instructions Addressing Modes LDD $9000 EXT CPU ACCA ACCB ACCD Description ; ACCD loaded with contents ; from memory address $9000 ; & $9001 Memory Content Address $56 $78 $44 $9000 $9001 $9002 6

Sample of Load Instructions (4) Instructions Addressing Modes LDAA $10, X IND CPU IND

Sample of Load Instructions (4) Instructions Addressing Modes LDAA $10, X IND CPU IND X Description ; ACCA loaded with contents ; from memory address (offset ; + X) Memory Content Address $22 9020 $33 ACCA $44 Data Flows $902 E $902 F $9030 7

STORE Instructions Store Instructions : 68 HC 11 Example: STAA , STAB , STD

STORE Instructions Store Instructions : 68 HC 11 Example: STAA , STAB , STD , STX , STY - Instructions store or place contents of any CPU registers to a memory or I/O location. Memory CPU Registers Data Flows I/O 8

Sample of Store Instructions (1) Instructions Addressing Modes Description STAA $10 DIR ; Place

Sample of Store Instructions (1) Instructions Addressing Modes Description STAA $10 DIR ; Place contents of ACCA into ; memory location ($0010). Memory Content CPU ACCA $22 $33 $90 Data Flows $44 Memory Address $000 F $0010 $0011 9

Sample of Store Instructions (2) Instructions Addressing Modes STAA $1000 EXT Description ; Place

Sample of Store Instructions (2) Instructions Addressing Modes STAA $1000 EXT Description ; Place contents of ACCA into ; memory location ($1000). Memory Content CPU ACCA $22 $33 $E 0 Data Flows $44 Memory Address $0 FFF $1000 $1001 10

Sample of Store Instructions (3) Instructions Addressing Modes Description STX $60 DIR ; Place

Sample of Store Instructions (3) Instructions Addressing Modes Description STX $60 DIR ; Place contents of IX into CPU ; memory location $0060 and ; $0061 Memory Content Address IX Register $22 $33 $12 $34 $1234 Data Flows $44 $005 F $0060 $0061 11

Sample of Store Instructions (4) Instructions Addressing Modes STAA $20, Y IND Description ;

Sample of Store Instructions (4) Instructions Addressing Modes STAA $20, Y IND Description ; Place contents of ACCA into ; memory location $20 + Y CPU IY Memory Content $8000 $22 $33 $E 0 ACCA Data Flows $44 Memory Address $801 E $801 F $8020 12

TRANSFER Instructions 68 HC 11 Transfer Instructions: Example: TAB , TBA TAB => Transfer

TRANSFER Instructions 68 HC 11 Transfer Instructions: Example: TAB , TBA TAB => Transfer ACCA to ACCB. - Instruction TAB will move (or copy) the contents of ACCA to ACCB. ACCA ACCB - If contents ACCA = $38 & ACCB = $9 F - Executing TAB, will result in ACCA = ACCB = $38 TAB 13

TRANSFER Instructions Example: TBA = Transfer (or copy) contents of ACCB to ACCA. If

TRANSFER Instructions Example: TBA = Transfer (or copy) contents of ACCB to ACCA. If contents of ACCA = $42 & ACCB = $8 E 68 HC 11 TBA $42 $8 E ACCA ACCB 14

EXCHANGE Instructions Exchange Instructions 68 HC 11 Examples: XGDX , XGDY • XGDX instruction

EXCHANGE Instructions Exchange Instructions 68 HC 11 Examples: XGDX , XGDY • XGDX instruction will transfer the contents of ACCD to Index-X (IX) register and the contents of IX will transfer to ACCD IX 15

EXCHANGE Instructions Example: XGDY : Instruction will transfer the contents of ACCD to Index-Y

EXCHANGE Instructions Example: XGDY : Instruction will transfer the contents of ACCD to Index-Y (IY) register and the contents of IY will transfer to ACCD. 68 HC 11 $1234 ACCD XGDY $5678 IY 16

Load, Transfer and Exchange Instructions Examples: LDAA #$59 ; Load ACCA with data $59

Load, Transfer and Exchange Instructions Examples: LDAA #$59 ; Load ACCA with data $59 LDAB #$2 A ; Load ACCB with data $2 A TAB LDX XGDX LDY XGDY ; Transfer contents of ACCA to ACCB #$4567 ; Load IX register with data $4567 ; Exchange contents of IX and ACCD #$1122 ; Load IY with data $1122 ; Exchange contents of IY and ACCD 17

Load, Transfer and Exchange Instructions Examples: LDAA #$59 LDAB #$2 A TAB LDX #$4567

Load, Transfer and Exchange Instructions Examples: LDAA #$59 LDAB #$2 A TAB LDX #$4567 A $59 $11 $45 B $2 A $67 $22 $59 A, B $4567 $1122 $5959 $592 A D $5959 $4567 IX $1122 $4567 IY XGDX LDY #$1122 XGDY 18

Thank You 19

Thank You 19