8051 Instruction Set

35
The 8051 Microcontroller: Instruction Set

description

A short presentation on instruction set of MC-8051

Transcript of 8051 Instruction Set

Page 1: 8051 Instruction Set

The 8051 Microcontroller:Instruction Set

Page 2: 8051 Instruction Set

1. BYTE INSTRUCTION:

i. MOV A, Rn (Rn ranges)

ii. MUL AB

3. BYTE INSTRUCTION:

i. DNJZ Rn, rel

ii. SUBB A, direct address

5. BYTE INSTRUCTION

i. ANL direct, #data

ii. MOV direct, #data

Length of Instructions:

Page 3: 8051 Instruction Set

1.ARITHMETIC INSTRUCTION.

3.DATA TRANSFER INSTRUCTION.

5.LOGICAL INSTRUCTION.

7.BRANCHING INSTRUCTION.

9.LOGICAL OPERATION ON BITS INSTRUCTION.

Classification of instructions:

Page 4: 8051 Instruction Set

ARITHMETIC OPERATIONS.

LENGTH-

1 OR 2.

FLAGS AFFECTED.

Arithmetic instruction

Page 5: 8051 Instruction Set

FUNCTION.

LENGTH.

FLAGS AFFECTED.

ADDRESSING MODE.

ADD A, Rn

Page 6: 8051 Instruction Set

Before executionADD A, R3

A13

B

R0 R1

R2 R331

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 7: 8051 Instruction Set

After executionADD A, R3

A44

B

R0 R1

R2 R331

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 1

Page 8: 8051 Instruction Set

FUNCTION.

LENGTH.

FLAGS AFFECTED.

ADDRESSING MODE.

INC Rn

Page 9: 8051 Instruction Set

Before executionINC A

A1F

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 10: 8051 Instruction Set

After executionINC A

A20

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 11: 8051 Instruction Set

SOURCE TO DESTINATION.

LENGTH.

FLAGS AFFECTED.

MOV/MOVC/MOVX

Data transfer group

Page 12: 8051 Instruction Set

FUNCTION.

MOV <destination byte>,<source Byte>

Flags affected.

Length-1, 2 or 3

Source-Destination combo.

Page 13: 8051 Instruction Set

Before executionMOV A, R7

A00

B

R0 R1

R2 R3

R4 R5

R6 R714

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 14: 8051 Instruction Set

After executionMOV A, R7

A14

B

R0 R1

R2 R3

R4 R5

R6 R714

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 15: 8051 Instruction Set

FUNCTION.

FLAGS AFFECTED.

LENGTH.

COMPULSORY OPERAND.

XCH A, Rn

Page 16: 8051 Instruction Set

Before executionXCH A, R5

A27

B

R0 R1

R2 R3

R4 R572

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 17: 8051 Instruction Set

After executionXCH A, R5

A72

B

R0 R1

R2 R3

R4 R527

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 18: 8051 Instruction Set

PERFORMS LOGICAL OPERATIONS.

LENGTH-1,2 OR 3

FLAG AFFECTED.

Logical group

Page 19: 8051 Instruction Set

FUNCTION.

FLAGS AFFECTED.

LENGTH.

ANL A, R0

Page 20: 8051 Instruction Set

Before executionANL A, R2

A10

B

R0 R1

R201

R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 21: 8051 Instruction Set

After executionANL A, R2

A00

B

R0 R1

R201

R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 22: 8051 Instruction Set

FUNCTION.

FLAGS AFFECTED.

LENGTH.

CPL A

Page 23: 8051 Instruction Set

Before executionCPL A

AFF

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 24: 8051 Instruction Set

After executionCPL A

A00

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 25: 8051 Instruction Set

TRANSFERS PROGRAM CONTROL.

LENGTH.

FLAGS AFFECTED.

Branching Instructions

Page 26: 8051 Instruction Set

FUNCTION.

LENGTH-

2 OR 3

FLAGS AFFECTED.

DJNZ <byte>,<rel-address>

Page 27: 8051 Instruction Set

FUNCTION.

LENGTH.

FLAGS AFFECTED.

JNZ rel

Page 28: 8051 Instruction Set

FUNCTIONS.

PERFORMED ON BITS.

LENGTH-

1 OR 2

Logical operations on Bit

Page 29: 8051 Instruction Set

FUNCTION.

LENGTH-

1 OR 2

FLAGS AFFECTED.

CLR bit

Page 30: 8051 Instruction Set

Before executionCLR C

AFF

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

1 0 - 1 1 0 - 0

Page 31: 8051 Instruction Set

After executionCLR C

AFF

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 32: 8051 Instruction Set

FUNCTION.

LENGTH-

1 OR 2

FLAGS AFFECTED.

CPL bit

Page 33: 8051 Instruction Set

Before executionCPL C

AFF

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

0 0 - 1 1 0 - 0

Page 34: 8051 Instruction Set

After executionCPL C

AFF

B

R0 R1

R2 R3

R4 R5

R6 R7

CY AC F0 RS1 RS0 OV - P

1 0 - 1 1 0 - 0

Page 35: 8051 Instruction Set

By:Mayank Sharma