I've been reverse-engineering a 6303/6800 binary from the early 1980s, which includes a subroutine for jumping to one entry in a table of relative offsets in memory, based upon whether the value of a variable is lower than an offset's associated index value. It's similar to C's switch statement, but not quite the same.
In this implementation the table of two byte entries is defined adjacent to the subroutine call, so that the table address will be pushed onto the stack as the subroutine return address. This address is then popped off the stack in the subroutine, and then iterated over.
Please forgive what may be an ignorant question. I'm somewhat new to 8-bit programming. I'm wondering if this technique had a common name at one point. Since I'm working backwards from the binary, I'm left to add my own names.
In my work with it, someone referred to it as a 'jumpoff', and for the lack of a name the term stuck. See below for the definition, and an example usage.
; Definition
jumpoff: SUBROUTINE
PULX
.test_table_entry_offset:
; If the current jump table entry number is '0', the end of the jump table has
; been reached, so exit.
TST 1,x
BEQ .load_offset_and_jump
; If the value in the entry 'index' is higher than the value in ACCB being
; tested, jump to the relative offset contained in this entry.
CMPB 1,x
BCS .load_offset_and_jump
INX
INX
BRA .test_table_entry_offset
.load_offset_and_jump:
; Load the relative offset in the current entry, add this to the return
; address popped from the stack, and jump to it.
PSHB
LDAB 0,x
ABX
PULB
JMP 0,x
; Invocation.
LDAA ui_mode_memory_protect_state
JSR jumpoff
DC.B input_slider - *
DC.B 1
DC.B input_button_yes_no - *
DC.B 3
DC.B input_button_main - *
DC.B 8
DC.B input_button_numeric - *
DC.B 0
If anyone is wondering where this came from, it came from the Yamaha DX7/9 ROM binaries. The annotated assembly is from a project of mine working with them: https://github.com/ajxs/yamaha_dx97