8051 family microcontrollers instruction set · 2011 microcontrollers-... 2nd ed. raj kamal pearson...

63
8051 Family Microcontrollers 8051 Family Microcontrollers Instruction Set Instruction Set Chapter 4

Upload: duongduong

Post on 03-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

8051 Family Microcontrollers 8051 Family Microcontrollers

Instruction SetInstruction Set

Chapter 4

Page 2: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

Data Transfer Instructions

Lesson 3

Page 3: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education3

Move byte between

accumulator (an SFR) and

register at a register bank

Page 4: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education4

MOV Rn, A

ARn

Destination Source

Page 5: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education5

MOV A, Rn

RnA

DestinationSource

Page 6: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education6

8051

Bank 3

Bank 2

RnA

MOV A, MOV A, RnRn; MOV Rn, A; MOV Rn, A

Bank 1

Bank 0

R7

R6

R4

R5

R3

R2

R1

R0

Page 7: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education7

Rn: n = 0,1, 2, 3,4, 5, 6,or 7,

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

Rn

n is as per 3 bits coexisting with 5-bits with opcode

Page 8: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education8

Instruction Execution

Fetch bits

for getting the

operand(s)

Fetch

opcode-bitsSTEP 1

STEP 2

Register addressing mode

Time

1 clock

cycle

Page 9: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education9

Move byte from an SFR/Internal RAM

to another direct

Page 10: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education10

MOV A, direct; MOV Rn, direct;MOV A, direct; MOV Rn, direct;

MOV direct, A; MOV direct, RnMOV direct, A; MOV direct, Rn

Page 11: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education11

An SFR or Internal RAM between

00H-7FH

A or Rndirect

DestinationSource

Page 12: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education12

8051

Bank 3

Bank 2

RnA

Bank 1

Bank 0

or

Direct addressed

SFR 80H-FFH or

Internal RAM

between 00H-

7FH

Page 13: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education13

An SFR or Internal RAM between

00H-7FH

directA or Rn

DestinationSource

Page 14: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education14

Instruction Execution

Fetch direct

Fetch

opcode-bitsSTEP 1

STEP 2

direct addressing mode

Time

1 clock

cycle

Page 15: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education15

MOV direct, direct

Page 16: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education16

8051

directdirect

Direct

addressed SFR

or Internal

RAM between

00H-7FH

MOV direct, directMOV direct, direct

Direct

addressed

SFR or

Internal

RAM

between

00H-7FH

Page 17: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education17

Instruction Execution

Fetch direct

Fetch

opcode-bitsSTEP 1

STEP 2

both the operands using direct addressing

modes

Time

2 clock

cycles

Fetch directSTEP 3

Page 18: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education18

Move indirect

Page 19: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education19

MOV A, @Ri; MOV A, @Ri;

MOV @Ri, A;MOV @Ri, A;

MOV direct, @Ri; MOV direct, @Ri;

MOV @Ri, directMOV @Ri, direct

Page 20: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education20

An indirect addressed Internal

RAM between 00H-FFH

Address

pointed by

R0 or R1

A or direct

DestinationSource

Page 21: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education21

8051

A or directindirect

SFR direct

addressed

between 80H-

8FH or A

register

Indirect

addressed

Internal

RAM

between

00H-FFH

Page 22: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education22

An indirect Internal RAM

between 00H-FFH

A or directAddress

pointed

by R0 or

R1

DestinationSource

Page 23: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education23

8051

Bank 3

Bank 2

R0 or R1

A

Bank 1

Bank 0

or

Pointed address

Internal RAM

between 00H-

FFH

12 3

direct

4

Page 24: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education24

Instruction Execution

Fetch bits for A

or direct

Fetch

opcode-bitsSTEP 1

STEP 2

indirect addressing mode one operand

Time

1 or 2

clock

cycle(s)

Fetch bit for i 0

or 1STEP 3

2 cycles when direct, 1 when A other operand

Page 25: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education25

1. No indirect addressing in 8051

instruction for an SFR

2. Only indirect addressing in 8052

instruction Internal RAM between

80H-FFH

Instruction Execution

Page 26: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education26

Move immediate,

MOV immediate DPTR

Page 27: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education27

byteA

2nd Byte of

instructionA register

Page 28: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education28

MOV A,#data Example

Fetch opcode

and then byte

for getting the

operand for

move

MOV A, #08H

Time

1 clock

cycle

Sign # specifies that 08H is

the immediate succeeding

byte is the operand

For moving

08H into A

register

Codes in

Memory-

74H, 08H

Page 29: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education29

8051

byteRn

2nd Byte of

instruction

Rn (R0 or

R1 or ...R6

or R7) at

Bank 0 or

1or 2 or 3

Page 30: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education30

MOV Rn,#data

Fetch opcode

and then byte

for getting the

operand for

move

MOV Rn, #08H

Time

1 clock

cycle

Sign # specifies that 08H is

the immediate succeeding

byte is the operand

For moving

08H into Rn

register

Codes in

Memory-

78H-7FH,

08H

Page 31: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education31

8051

bytedirect

2nd Byte of

instruction

direct

address

internal

RAM 00H-

7FH or

SFR 80H-

FFH

Page 32: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education32

MOV direct,#dataFetch opcode and

then bytes

for getting the

operands

MOV direct, #08H

Time

2 clock

cycles

Sign # specifies that 08H is the

immediate succeeding byte is the

operand

For moving

08H into direct

Codes in

Memory-

75H, 00H-

FFH, 08H

Page 33: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education33

Destination Direct Addressing

Fetch byte(s)

after the

opcode

STEP 2

Addressing mode specifies that fetch

byte(s) (next to the opcode of 8 bits)

specify an address, destination operand is

at that address.

Time

clock

cycle (s)

Page 34: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education34

8051

byteindirect

2nd Byte of

instruction

indirect

address

internal

RAM 00H-

FFH

pointed by

R0 or R1

Page 35: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education35

MOV @Ri,#data

Fetch opcode

and then bits

for getting the

operands

MOV @Ri, #08H

Time

1 clock

cycle

Sign # specifies that 08H is

the immediate succeeding

byte is the operand

For moving

08H into

indirect

Codes in

Memory-

76-77H,

08H

Page 36: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education36

Destination indirect

Addressing

Fetch bit 0 or

1 for R0 or R1

the opcode

STEP 2

Addressing mode specifies that fetch

byte(s) specify by an address pointed by

R0 or R1 at a bank

Time

1 clock

cycle

Page 37: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education37

• A

• Rn

• direct for Internal RAM in between

00H to 7FH or direct for SFR 80H-

FFH

• Indirect using R0 or R1

Immediate Addressing Four type of

instructions

Page 38: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education38

• Lower byte is second byte of the

instruction and is for DPL

• Higher byte is third byte of the

instruction and is for DPH

Immediate addressing mode for

source two-bytes

Page 39: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education39

MOV DPTR, #data16

Fetch opcode

and then 16

bits for getting

the operands

MOV DPTR, #08C1H

Time

2 clock

cycles

Sign # specifies that 08C1H is

two immediate succeeding

bytes as the operand

For moving

08C1H into

DPTR

Codes in

Memory-

90H, C1H,

08H

Page 40: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education40

MOVC and MOVX indirect

Page 41: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education41

2. Only indirect addressing in 8051

instruction for a code in internal/external

program memory

1. Only indirect addressing in 8051

instruction for a byte in external data

memory

Page 42: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education42

Always Indirect Addressing mode

Internal/External

Program Memory

(max. 64kB)

External Data Memory

and Ports (max 64kB)

Page 43: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education43

MOVC A, @A + PC

Fetch opcode

bits

STEPS 2-3

MOVC A, @A + PC

Time

2 clock

cycles

indirectly specify, PC16-bits adds

with 8-bits at A register and then

new 16-bits point to the code at

that address

For

transferring

addressed

code byte

into A

Code bits in

Memory-

83H

C means code

memory is used

Page 44: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education44

MOVC A, @A + DPTR

Fetch opcode

bits

STEPS 2-3

MOVC A, @A + DPTR

Time

2 clock

cycles

indirectly specify, DPTR16-bits

adds in 8-bits at A register and

then 16-bits point to code at that

address

For

transferring

addressed

code byte

into A

Code bits in

Memory-

93H

C means code

memory is used

Page 45: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education45

MOVX A, @DPTR

Fetch opcode

STEP 2MOVX A, @DPTR

Time

2 clock

cycles

X specifies external memory,

byte at DPTR points indirectly

to the address for the operand

For

transferring

an external

byte into A

Code bits in

Memory-

E0H

Sign @ means

DPTR is a

pointer

Page 46: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education46

MOVX @DPTR, A

Fetch opcode

STEP 2

MOVX @DPTR, A

Time

2 clock

cycles

X specifies external memory,

byte at DPTR points indirectly

to the address for the operand

For

transferring A

to a byte at

external

pointed address

Code bits in

Memory-

F0H

Sign @ means

DPTR is a pointer

Page 47: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education47

MOVX A, @Ri

Fetch opcode

STEP 2MOVX A, @Ri

Time

2 clock

cycles

X specifies external memory,

byte at Ri points indirectly to an

external memory address for the

operand

For

transferring an

external byte

into A

Code bits in

Memory- E2-

E3H

Sign @ means Ri

is a pointer

Page 48: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education48

MOVX @Ri, A

Fetch opcode

MOVX @Ri, A

Time

2 clock

cycles

X specifies external memory,

byte at Ri points indirectly to the

address for the operand

For transferring

A to a byte at

external pointed

address

Code bits in

Memory- F2-

F3H

Sign @ means Ri

is a pointer

Page 49: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education49

Push or Pop direct or Exchange or

Swap

Page 50: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education50

Always direct Addressing mode

for Push or Pop

Internal data Memory

(00H-7FH)

SFR (80H-FFH)

Page 51: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education51

8051

SP

direct

Increment SP

Move the byte to SP

pointed address

1

2

3

stack4

Push direct

Direct address

SFR or

internal 00-

7FH RAM

SP is of 8-bits

Page 52: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education52

8051

SP

direct

Move the byte to

SP pointed address

and decrement SP

1

2

4

stack3

Pop direct

Direct

address SFR

or internal

00-7FH RAM

SP is of 8-bits

Page 53: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education53

Instruction Execution

Fetch byte direct

Fetch

opcode-bitsSTEP 1

STEP 2

direct addressing mode for source operand in

push and for destination operand for pop

Time

2 clock

cycles

Page 54: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education54

Push an SFR or Internal RAM

between 00H-7FH

directstack

DestinationSource

Pre-increment SP

Page 55: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education55

Pop an SFR or Internal RAM

between 00H-7FH

stackdirect

DestinationSource

Post-decrement SP

Page 56: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education56

Exchange of A register byte with

other

Internal data Memory

(00H-FFH)

SFR (80H-FFH)

A register

Page 57: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education57

8051Temp

A

Rn or

internal

RAM or

SFR

1

2

3

XCH A, Rn, XCH A, direct,

XCH A, @Ri; exchange bytes

A register

Page 58: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education58

Exchange of A register lower digit with

other

Internal data Memory

(00H-FFH)

SFR (80H-FFH)

A register

Page 59: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education59

8051

temp

bit3-bit0

A register lower 4

bits

12 4

bit3-bit03

XCHD A, @Ri;

exchange lower

digits (4-bits)

Indirect

address

internal 00-

FFH RAM

pointed by

R0 or R1

Page 60: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education60

Exchange of A register lower digit

with higher digit

A register higher

bits

A register

lower bits

Page 61: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education61

8051

temp

bit7-bit4

A register lower 4

bits

23 5

bit3-bit04

SWAP A; exchange of lower digit (4-

bits) with higher at A

A register

higher 4 bits

61

Page 62: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education62

Summary

Page 63: 8051 Family Microcontrollers Instruction Set · 2011 Microcontrollers-... 2nd Ed. Raj Kamal Pearson Education 3 Move byte between accumulator (an SFR) and register at a register bank

2011 Microcontrollers-... 2nd Ed. Raj Kamal

Pearson Education63

8051 family data transfer

instructions

• move (copy)

• push

• pop

• exchange

• exchange lower 4-bits

We learnt