Beruflich Dokumente
Kultur Dokumente
Lesson 3
Move byte between accumulator (an SFR) and register at a register bank
2011
MOV Rn, A
Destination Source
Rn
2011
MOV A, Rn
Destination Source
Rn
2011
Rn
8051
2011
Rn
Rn: n = 0,1, 2, 3,4, 5, 6,or 7, n is as per 3 bits coexisting with 5-bits with opcode
Register n is at the bank defined by RS1 and RS0 at PSW - 00 means Bank 0, -01 bank 1 - 10 bank 2- 11 bank 3
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 7
Instruction Execution STEP 1 STEP 2 Fetch opcode-bits Fetch bits for getting the operand(s)
1 clock cycle
Time
2011
2011
2011
10
direct
A or Rn
2011
11
or
Rn
8051
2011
A or Rn
direct
2011
13
1 clock cycle
Time
2011
14
2011
15
8051
2011
Instruction Execution STEP 1 STEP 2 STEP 3 Fetch opcode-bits Fetch direct Fetch direct
2 clock cycles
Time
2011
17
Move indirect
2011
18
MOV A, @Ri; MOV @Ri, A; MOV direct, @Ri; MOV @Ri, direct
2011
19
A or direct
Address pointed by R0 or R1
20
2011
indirect
A or direct
8051
2011
Address pointed by R0 or R1
2011
A or direct
22
or 4
direct R0 or R1
8051
2011
Instruction Execution
STEP 1 STEP 2 STEP 3 Fetch opcode-bits Fetch bits for A or direct Fetch bit for i 0 or 1
1 or 2 clock cycle(s)
Time
indirect addressing mode one operand 2 cycles when direct, 1 when A other operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 24
Instruction Execution 1. No indirect addressing in 8051 instruction for an SFR 2. Only indirect addressing in 8052 instruction Internal RAM between 80H-FFH
2011
25
2011
26
byte
A register
2011
27
Fetch opcode and then byte for getting the operand for move
Sign # specifies that 08H is the immediate succeeding byte is the operand
2011
Rn
byte
8051
2011
29
MOV Rn,#data Fetch opcode For moving and then byte 08H into Rn for getting the register operand for move MOV Rn, #08H Sign # specifies that 08H is the immediate succeeding byte is the operand
2011
30
direct
byte
8051
2011
31
MOV direct,#data
For moving 08H into direct Fetch opcode and then bytes for getting the operands
2 clock cycles
MOV direct, #08H Sign # specifies that 08H is the immediate succeeding byte is the operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education
Addressing mode specifies that fetch byte(s) (next to the opcode of 8 bits) specify an address, destination operand is at that address.
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 33
indirect
byte
8051
2011
34
MOV @Ri,#data Fetch opcode For moving and then bits 08H into for getting the indirect operands MOV @Ri, #08H Sign # specifies that 08H is the immediate succeeding byte is the operand
2011
Addressing mode specifies that fetch byte(s) specify by an address pointed by R0 or R1 at a bank
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 36
Lower byte is second byte of the instruction and is for DPL Higher byte is third byte of the instruction and is for DPH
2011
38
MOV DPTR, #data16 2 clock Fetch opcode cycles For moving and then 16 08C1H into bits for getting Time DPTR the operands MOV DPTR, #08C1H
Sign # specifies that 08C1H is two immediate succeeding bytes as the operand 2nd Ed. Raj Kamal Microcontrollers-... 2011
Pearson Education
2011
40
1. Only indirect addressing in 8051 instruction for a byte in external data memory
2. Only indirect addressing in 8051 instruction for a code in internal/external program memory
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 41
2011
42
MOVC A, @A + PC indirectly specify, PC16-bits adds with 8-bits at A register and then new 16-bits point to the code at that address Microcontrollers-... 2nd Ed. Raj Kamal 2011
Pearson Education
MOVC A, @A + DPTR
For transferring addressed code byte into A
MOVC A, @A + DPTR
indirectly specify, DPTR16-bits adds in 8-bits at A register and then 16-bits point to code at that C means code address memory is used Microcontrollers-... 2nd Ed. Raj Kamal 44 2011
Pearson Education
MOVX A, @DPTR For Fetch opcode transferring Sign @ means an external DPTR is a byte into A pointer MOVX A, @DPTR X specifies external memory, byte at DPTR points indirectly to the address for the operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education
2 clock cycles
Time
STEP 2
Code bits in MemoryE0H
45
MOVX @DPTR, A
For transferring A to a byte at external pointed address
Fetch opcode
Sign @ means DPTR is a pointer
MOVX @DPTR, A
X specifies external memory, byte at DPTR points indirectly to the address for the operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education
46
MOVX A, @Ri For Fetch opcode transferring an external byte Sign @ means Ri is a pointer into A MOVX A, @Ri X specifies external memory, byte at Ri points indirectly to an external memory address for the operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education
2 clock cycles
Time
STEP 2
Code bits in Memory- E2E3H
47
MOVX @Ri, A
For transferring Fetch opcode A to a byte at external pointed Sign @ means Ri is a pointer address MOVX @Ri, A X specifies external memory, byte at Ri points indirectly to the address for the operand
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education
48
2011
49
2011
50
direct
4
SP
stack
1
8051 Direct address SFR or internal 007FH RAM
Push direct
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 51
direct
2 8051 Direct address SFR or internal 00-7FH RAM
3 SP
stack
Pop direct
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 52
2 clock cycles
Time direct addressing mode for source operand in push and for destination operand for pop
2011
53
Pre-increment SP
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 54
Post-decrement SP
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 55
A register
2011
56
A 1 8051 A register
Exchange of A register lower digit with other Internal data Memory (00H-FFH) SFR (80H-FFH)
A register
2011
58
3
temp
bit3-bit0 4 1
2011
59
2011
60
4 temp 5
bit3-bit0
2
2011
61
Summary
2011
62
We learnt 8051 family data transfer instructions move (copy) push pop exchange exchange lower 4-bits
2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 63