Review Questions : 1. What are the uses of LCALL and LJUMP instructions of 8051 ? 2. Explain about the instruction DJNZ.
Jump and CALL Instructions
Jump
and CALL instructions change the flow of the program by changing the contents
of program counter. A jump permanently changes the program flow whereas call
temporarily changes the program flow to allow another part of the program to
run.
There
are jump instructions which change the program flow if certain condition
exists. For example, CJNE (compare and jump if not equal). This instruction
compares the magnitude of the first two operands, and changes program flow if
their values are not equal.
The
following types of instructions change the program flow :
■
Jump on bit conditions.
■
Compare byte and jump if not equal.
■
Decrement byte and jump if zero.
■
Jump unconditionally.
■
Call a subroutine.
■
Return from a subroutine.
We
know that a jump and call instructions replace the contents of the program
counter with a new program address. The new address can be specified either by
specifying the difference between the new address and the current program
counter contents or by specifying the entire new address. The difference, in
bytes, of the new address from the address in the program counter is called the
range of the jump or call. For example, if a jump instruction is located at
program address 0200H, and the jump causes the program counter to become 0230H,
then the range of the jump is 30H bytes. Jump and CALL instructions may have
one of the three ranges.
■
Relative (short) range : +127 to - 128 (+7FH to - 80H)
■
Absolute range : 0000H to 07FFH
■
Long range : 0000H to FFFFH
2. Jump
The
Table 15.8.1 shows the list of jump instructions supported by 8051.
There
are two subroutine-call instructions. LCALL (Long Call) and ACALL (Absolute
Call). Each increments the PC to the first byte of the following instruction,
then pushes it onto the stack (low byte first). Saving both bytes increment the
stack pointer by two. The subroutine's starting address is encoded in the same
ways as LJMP and AJMP. The generic form of the call operation is the mnemonic
CALL, which 8051 will translate into LCALL or ACALL as appropriate.
The
return instruction RET pops the high and low-order bytes of the program counter
successively from the stack, decrementing the stack pointer by two. Program
execution continues at the address previously pushed : The first byte of the
instruction immediately following the call.
Review Questions
1. What are the uses
of LCALL and LJUMP instructions of 8051 ?
2. Explain about the instruction DJNZ.
Microprocessors and Microcontrollers: Unit III: (b) 8051 Instruction Set and Programming : Tag: : 8051 Instruction Set and Programming - Jump and CALL Instructions