Program branch group in 8051


In 8051 Microcontroller there is 17 different instructions under the Logical Group. In total there are 46 opcodes. These instructions do not affect the flag bits but the CJNE affects the CY flag. In these instructions, the 11-bit address and 16-bit addresses are used.

In the following table, we will see the Mnemonics, Lengths, Execution Time in terms of the machine cycle, Number of Opcodes etc.

Mnemonics
Byte Count
ExecutionTime
Opcode Count
ACALL addr11
2
2
8
LCALL addr16
3
2
1
RET
1
2
1
RETI
1
2
1
AJMP addr11
2
2
8
LJMP addr16
3
2
1
SJMP rel
2
2
1
JMP @A+DPTR
1
2
1
JZ rel
2
2
1
JNZ rel
2
2
1
CJNE A, a8, rel
3
2
1
CJNE A, #d8, rel
3
2
1
CJNE Rn, #d8, rel
3
2
8
CJNE @Ri, #d8, rel
3
2
2
DJNE Rn, rel
2
2
8
DJNZ a8, rel
3
2
1
NOP
1
1
1


Examples

Sr.NoInstruction & Description
1LJMP LABEL
This is an example of LJMP addr16. The LJMP stands for the long jump. It can jump to the symbolic location label. The address is generated by assembler from the value of label. Using this instruction, we can jump anywhere in the program.
2ACALL SUBR
This is an instruction of ACALLa ddr11 type. The ACALL is the absolute call. Using this instruction, it calls a subroutine from the symbolic location SUBR. Before call, it stores the value of Program Counter, at the top of the stack.
3SJMP LABEL
This instruction is like SJMP rel.SJMP means Short jump. Here the LABEL is an 8-bit address generated by the assembler. Using this instruction we can halt the program in8051.
4JZ LABEL
This instruction is of like JZ rel instruction. When the value of A register is 00h, then only it jumps to LABEL, otherwise, it will be ignored. The assembler generates 8-bit signed displacement from the instruction.
5RET
This is return instruction. When it is executed, the next address of the program counter is popped from the stack top, and the value of SP is decremented by 2.
6RETI
This is Return from Interrupt. This is also like RET instruction. But it restores the interrupt logic also. So after restoring it can accept additional interrupts at the same priority level.
7DJNZ 80H, LABEL
This is like DJNZ a8, rel. It means Decrement and Jump if not zero. So the port P0 contents are decremented by 1. When the value is not 00H after the decrement, the branch instruction takes place. Here the LABEL is a signed8-bit number.
8CJNE R5, #90H, LABEL
This is like the instruction CJNE Rn, #d8, rel. The CJNE stands for Compare and Jump if not Equal. So itis a combined instruction of compare and jump. Here the content ofR5 is compared with 90H. When the values are not same it jumps to a label. The LABEL is 8-bit signed number.


During execution of ACALL or  AJMP, we can think that the program memory is divided into 2K byte block. From the 16-bit address, the first five bits are fixed. Further the block of 2K memory that can be divided into 256-byte pages. So we need 3 bits to select the pages.

There are three kinds of unconditional jumps. The SJMP, LJMP, and AJMP, but two kinds of unconditional call instruction ACALL, LCALL. No SCALL is present.


Updated on: 27-Jun-2020

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements