1. Program flow instructions in 8051
(Conditional and
Unconditional jump
Instructions)
A.Usha Rani
Faculty,
Department of Physics and Electronics
St.Ann’s College for Women.
2. Program flow instructions
These instructions are used to control the flow of
execution of the program or to change the sequence of
program execution.
They are also called Branch instructions or Jump
Instructions.
Change the content of program counter to change
the program execution order.
3. Unconditional Jumps
Do not test any condition and Jump is taken always.
Short Jump
The program can jump to an instruction within 127 bytes
in forward direction or 128 bytes in reverse direction.
Also called relative jump because the address where the
jump can be taken is relative to the address where the
instruction is written.
The instruction is SJMP rel (Jump to relative address rel)
4. Long Jump
Used to jump to any location within entire program
address space i.e., anywhere from 0000H to FFFFH.
3 byte instruction and is mostly used in large programs.
The instruction is LJMP address
Absolute Jump
The entire program memory is divide into 32 pages each
of 2K bytes each.
AJMP can be used to jump within a page of 2K.
The instruction is AJMP address
5. Conditional Jumps
Test the condition before taking a jump. Jump is taken
only if the condition given in the instruction is satisfied.
Bit Jumps
Check the status of a bit specified in the instruction
before taking the jump.
Jump is taken only if the condition specified in the
instruction is satisfied.
Used to monitor the status of a specified bit.
6. JC rel // Jump to relative address rel if C=1(Jump if
Carry)
JNC rel // Jump to relative address rel if C=0(Jump if
No Carry)
JB rel // Jump to relative address rel if bit =1(Jump
if Bit)
JNB rel // Jump to relative address rel if bit=0
(Jump if No Bit)
JBC bit, rel // Jump to relative address rel if bit =1 and
then clear bit (Jump if bit then clear)
7. Byte Jumps
Check the byte of a data to make jump.
JZ rel //Jump to relative address rel if A is
0(Jump if Zero)
JNZ rel // Jump to relative address rel if A is
not 0(Jump if Not Zero)
CJNE A, direct,rel //Compare A with the contents
of address direct and jump to relative
address rel if they are not equal. If the
contents of A are less than contents of
address direct, set carry =1 otherwise
clear carry(Compare and Jump if Not Equal)
8. CJNE A, #data,rel //Compare A with immediate
value data and jump to relative
address rel if they are not equal. If the
contents of A are less than immediate
value data, set carry =1 otherwise
clear carry
CJNE Rn, #data,rel //Compare Rn with the immediate
value data and jump to relative
address rel if they are not equal. If
the contents of Rn are less than
immediate value data, set carry =1
otherwise clear carry
9. CJNE @Ri, #data,rel //Compare contents of
address in Ri with immediate
value data and jump to relative address
rel if they are not equal. If the contents
of address in Ri are less than
immediate value data, set carry =1
otherwise clear carry
DJNZ Rn,rel //decrement register Rn by 1 and jump
to relative address rel if the contents of
Rn are not zero after decrement
operation.(Decrement and Jump if Not Zero)
10. DJNZ direct,rel //decrement contents of address
direct by 1 and jump to relative
address if the contents of address
direct are not zero after decrement operation.