Sunteți pe pagina 1din 26

INSTRUCTION SET OF 8051

Classification of Instruction Set of 8051

1. Data transfer instructions


2. Byte Level Logical Instructions
3. Bit Level Logical Instructions
4. Arithmetic Instructions
5. Jump and CALL instructions
Arithmetic Instructions

The arithmetic operations of 8051 include


1.Increment and decrement.
2.Addition
3.Subtraction
4. Multiplication
5.Division
INCREMENT AND DECREMENT OPERATIONS
ADDITION OPERATIONS
SUBTRACTION OPERATIONS
1. Multiplication : MUL AB
Lower order byte is left in the accumulator
Higher order byte is left in the B register

2. Division : DIV AB
Before Execution
A=dividend
B=divisor

After execution
A=quotient
B=remainder
DATA TRANSFER INSTRUCTION
DATA TRANSFER INSTRUCTION
DATA TRANSFER INSTRUCTION

Instructions to Access External Data Memory


(RAM)
DATA TRANSFER INSTRUCTION

Instructions to Access External ROM/program


memory
DATA TRANSFER INSTRUCTION

Data Exchange Instructions


Bit level logical Instructions
Bit level logical instructions are very convenient when it is
necessary to set or reset a particular bit in the internal RAM or
SFRs.
Sl.No Function
Sl.No Function
1. CLR C 6. ANL C, bit
2. SETB C 7. ANL C, / bit
3. SETB bit 8. ORL C, bit
9. ORL C, /bit
4. CPL C
10. MOV C, bit
5. CPL bit
11. MOV bit, C
Bit level logical Instructions
ROTATE AND SWAP INSTRUCTIONS

Sl.No Function

1. RL A
2. RLC A
3. RR A

4. RRC
5. SWAP A
JUMP and CALL Instructions

Sl.No Instructions Function

1. AJMP addr11 Absolute jump

2. LJMP addr16 Long jump

3. SJMP rel Short Jump


4. JMP @ A+DPTR Jump indirect relative to the
DPTR
5. JZ rel Jump if accumulator is zero

6. JNZ rel Jump if accumulator is not


zero
Sl.No Instructions Function
7. JC rel Jump if Carry is Set
8. JNC rel Jump if no carry flag
9. JB bit, rel Jump if direct bit set
10. JNB bit, rel Jump if direct bit is not set
11. JBC bit, rel Jump if direct bit set and
clear bit
12. CJNE <dest-byte>, Compare and Jump if Not
<scr-byte>,rel equal
13. DJNZ <byte>, rel Decrement and Jump if not
equal
14. NOP No operation
CALL and Subroutines
Sl.No Instructions Function

1. ACALL addr11 Absolute Call

2. LCALL addr16 Long CALL

3. RET Return from


subroutine
4. RETI Return from Interrupt
BYTE LEVEL LOGICAL INSTRUCTIONS
CONCEPT OF INTERRUPT

When one or more devices are connected to a


microcontroller system, any one of them
require service at a time.
 The microcontroller can service these
devices in one of the two ways:
1. Polling method
2. Interrupt method
Polling Method: In polling , the microcontroller’s
program simply checks each of the I/O devices to
see if any device needs servicing. If so, it
performs the service.

Interrupt Method: Upon receiving an interrupt


signal, the microcontroller by sending an interrupt
signal, the microcontroller stops executing its
current program and calls a subroutine called
Interrupt service routine which service the
interrupt.
Interrupt :
Sl.n Polling Method Interrupt method

1. In polling, a lot of microcontroller’s In interrupt method,


processing power is wasted in microcontroller’s time is not wasted
checking whether the I/O devices in checking whether the I/O devices
need service. need service.
2. Since all devices are polled in a Interrupt method can assign
sequential manner, there is no priorities to the interrupts so that
explicit priority mechanism in the they can be served according to
polling method. priority basis.
3. In polling, there is no possibility of In interrupt method, the
ignoring a device request for microcontroller can ignore(mask) a
service. device request for service.
4. In efficient way of handling I/O Efficient way of handling I/O
devices. devices.

5. No external hardware signal External hardware signal is


required. required to interrupt
microcontroller.
GENERAL CLASSIFICATION OF INTERRUPTS

1. Hardware interrupts
2. Software interrupts
3. Maskable interrupts
4. Unmaskable interrupts
5. Vectored interrupts
6. Non- vectored interrupts
INTERRUPT TYPES AND PRIORITIES IN 8051

• If two interrupt sources interrupt at the same time ,the


interrupt with the highest PRIORITY gets serviced first.

1. External interrupt 0 (INT0) 0003H- Highest


2. Timer interrupt 0 (TF0) 000BH
3. External interrupt 1 (INT1) 0013H
4. Timer interrupt1 (TF1) 001BH
5. Serial communication (RI+TI) 0023H- lowest

Note: All interrupts of 8051 are hardware, vectored


and maskable interrupt.

25
DATA TRANSFER INSTRUCTION

Data transfer with stack(PUSH and POP )


Instructions

PUSH direct: Push onto stack

POP direct: Pop from stack

S-ar putea să vă placă și