How do I utilize an ASM jmp instruction to move to the desired jump address in the C backend? I know how to do this in the ASM backend.
I do not and honestly cannot use prototypes or other methods to accomplish what I need. I have contemplated various code structures to perform similar functions but none are up to the task.
I am specifically looking on a way to implement an jmp instruction by index into a table of addresses in the C backend. Any code that would generate the same result would be welcome. Hints are also welcome.
Here is the pseudo-code (missing the code). The variables index_1, index_2 & index_3 are global and are set outside the procedure to direct the flow within the procedure. Speed is a top priority as the procedure will be used as a callback and will be called many times.:
Code: Select all
Procedure x()
;how to replace the Goto with an ASM instruction to jmp to the indexed address in the C Backend?
Goto ?jp_adr + (index_1 * SizeOf(Integer)) ;index_1 is an index into jump table.
set_1a:
;code + next jump
Goto ?jp_adr + (index_2 * SizeOf(Integer)) ;index_2 is an index into jump table.
set_1b:
;code + next jump
Goto ?jp_adr + (index_2 * SizeOf(Integer)) ;index_2 is an index into jump table.
set_1c:
;code + next jump
Goto ?jp_adr + (index_2 * SizeOf(Integer)) ;index_2 is an index into jump table.
set_2a:
;code + next jump
Goto ?jp_adr + (index_3 * SizeOf(Integer)) ;index_3 is an index into jump table.
set_2b:
;code + next jump
Goto ?jp_adr + (index_3 * SizeOf(Integer)) ;index_3 is an index into jump table.
set_2c:
;code + next jump
Goto ?jp_adr + (index_3 * SizeOf(Integer)) ;index_3 is an index into jump table.
set_3a:
;code + next jump
Goto exit
set_3b:
;code + next jump
Goto exit
set_3c:
;code
exit:
procedureReturn
DataSection
jp_adr:
Data.i ?set_1a, ?set_1b, ?set_1c, ?set_2a, ?set_2b, ?set_2c, ?set_3a, ?set_3b, ?set_3c
EndDataSection
EndProcedure