edit: changed to pointer array, mk-soft
Code: Select all
Structure ArrayOfPointer
*Index[0]
EndStructure
Procedure JumpTable_test(index)
Protected *addr.ArrayOfPointer = ?jt
Protected result
DataSection : jt:
Data.i ?l0 , ?l1 , ?l2 , ?l3 , ?l4
EndDataSection
If index < 5
CompilerIf #PB_Compiler_Backend = #PB_Backend_C
!goto *p_addr->f_index[v_index];
CompilerElse
EnableASM
jmp *addr\Index[index]
DisableASM
CompilerEndIf
Else
Goto lE
EndIf
l0:
result = 0
Goto lE
l1:
result = 1
Goto lE
l2:
result = 2
Goto lE
l3:
result = 3
Goto lE
l4:
result = 4
lE:
ProcedureReturn result
EndProcedure
Debug JumpTable_test(3)