Wednesday, March 23, 2016

8051 Indirect Jump

Jump Indirect - JMP @A+DPTR

JMP @A+DPTR adds the eight-bit unsigned contents of the Accumulator with the 16-bit data pointer and loads the resulting sum to the program counter. This is the address for subsequent instruction fetches. Sixteen-bit addition is performed (modulo 216): a carry-out from the low-order eight bits propagates through the higher-order bits. Neither the Accumulator nor the Data Pointer is altered. No flags are affected.

Encoding: 0 1 1 1 0 0 1 1

An even number from 0 to 6 is in the Accumulator. The following sequence of instructions branches to one of four AJMP instructions in a jump table starting at JMP_TBL.

MOV DPTR, # JMP_TBL
JMP @A + DPTR
JMP_TBL: AJMP LABEL0
AJMP LABEL1
AJMP LABEL2
AJMP LABEL3

If the Accumulator equals 04H when starting this sequence, execution jumps to label LABEL2. Because AJMP is a 2-byte instruction, the jump instructions start at every other address.

Example:
ORG 0H
MAIN :
MOV A, #00H
BEGIN :ADD A, #2H
MOV DPTR, # JMP_TBL
JMP @A + DPTR
JMP_TBL :AJMP LABEL1
AJMP LABEL2
AJMP LABEL3
LABEL1 :MOV P0, #00H
AJMP BEGIN
LABEL2 :MOV P0, #55H
AJMP BEGIN
LABEL3 :MOV P0, #0AAH
AJMP MAIN
END



Related topics:
8051 Unconditional and Conditional Jump   |   8051 Long Jump   |   8051 Absolute Jump   |   8051 Short 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