Wednesday, March 23, 2016

8051 Short Jump

Short Jump - SJMP addr8

Program control branches unconditionally to the address indicated. The branch destination is computed by adding the signed displacement in the second instruction byte to the PC, after incrementing the PC twice. Therefore, the range of destinations allowed is from 128 bytes preceding this instruction 127 bytes following it.

Encoding: 1 0 0 0 0 0 0 0 rel address

The label RELADR is assigned to an instruction at program memory location 0123H. The following instruction,

SJMP RELADR

assembles into location 0100H. After the instruction is executed, the PC contains the value 0123H.
Note: Under the above conditions the instruction following SJMP is at 102H. Therefore, the displacement byte of the instruction is the relative offset (0123H-0102H) = 21H. Put another way, an SJMP with a displacement of 0FEH is a one-instruction infinite loop. While in the case of a forward jump, the displacement value is a positive number between 0 to 127 (00 to 7F in hex), for the backward jump the displacement is a negative value of 0 to -128.

Example:
ORG 0H
MAIN :
MOV A, #00H
ADD A, #12H
...; Assume 100 bytes of code here
SJMP MAIN
END; end of asm source file



Related topics:
8051 Unconditional and Conditional Jump   |   8051 Long Jump   |   8051 Absolute Jump   |   8051 Indirect Jump   |   8051 Jump if Accumulator Zero   |   8051 Jump if Accumulator Not Zero   |   8051 Compare and Jump if Not Equal   |   8051 Decrement and Jump if Not Zero   |   8051 Jump if Carry is Set   |   8051 Jump if Carry is Not Set   |   8051 Jump if Bit Set   |   8051 Jump if Bit Not Set   |   8051 Jump if Bit is Set and Clear Bit

List of topics: 8051

No comments:

Post a Comment