SN8P1829
8-Bit MCU build-in 12-bit ADC + PGIA + Charge-pump Reg 128 dots LCD driver
SONiX TECHNOLOGY CO., LTD
Page 19
Version 1.0
JUMP TABLE DESCRIPTION
The jump table operation is one of multi-address jumping function. Add low-byte program counter (PCL) and ACC
value to get a new PCL. The new program counter (PC) points to a series jump instructions as a listing table. The way
is easy to make a multi-branch program.
When carry flag occurs after executing of “ADD PCL, A”, it will not affect PCH register. Users have to check if the jump
table leaps over the ROM page boundary or the listing file generated by SONiX assembler. If the jump table leaps over
the ROM page boundary (e.g. from xxFFH to xx00H), move the jump table to the top of next program memory page
(xx00H).
Here one page mean 256 words.
Example : If PC = 0323H (PCH = 03H
、
PCL = 23H)
ORG
0X0100
; The jump table is from the head of the ROM boundary
B0ADD
PCL, A
; PCL = PCL + ACC, the PCH can’t be changed.
JMP
A0POINT
; ACC = 0, jump to A0POINT
JMP
A1POINT
; ACC = 1, jump to A1POINT
JMP
A2POINT
; ACC = 2, jump to A2POINT
JMP
A3POINT
; ACC = 3, jump to A3POINT
In following example, the jump table starts at 0x00FD. When executing “B0ADD PCL, A”, ACC = 0 or 1, the
jump table points to the right address. If the ACC is larger then 1 will cause error because PCH doesn't
increase one automatically. We can see the PCL = 0 when ACC = 2 but the PCH still keep in 0. The program
counter (PC) will point to a wrong address 0x0000 and crash system operation. It is important to check
whether the jump table crosses over the boundary (xxFFH to xx00H). A good coding style is to put the jump
table at the start of ROM boundary (e.g. 0100H).
Example: Errors occurs if jump table’s range over ROM boundary.
ROM Address
. .
. .
. .
0X00FD
B0ADD
PCL, A
; PCL = PCL + ACC, the PCH can’t be changed.
0X00FE
JMP
A0POINT
; ACC = 0
0X00FF
JMP
A1POINT
; ACC = 1
0X0100
JMP
A2POINT
; ACC = 2
jump table cross boundary here
0X0101
JMP
A3POINT
; ACC = 3
. .
. .
SONiX provides a macro for safe jump table function. This macro checks the ROM boundary and move the jump table
to the right position. The side effect of this macro is maybe wasting some ROM size. Notice the maximum jump table
number for this macro is limited to 254.
@JMP_A MACRO
VAL
IF
(($+1) !& 0XFF00) !!= (($+(VAL)) !& 0XFF00)
JMP
($ | 0XFF)
ORG
($ | 0XFF)
ENDIF
ADD
PCL,
A
ENDM
Note: “VAL” is the number of the jump table listing number.