Signature for ROM based programs

Chat about anything CX16 related that doesn't fit elsewhere
BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

Signature for ROM based programs

Post by BruceMcF »


@TomXP411There is a higher overhead version of the above which integrates with a simple jump table in the first page of the ROM. Here the Toolbox ROM RTS's, and the trampoline works with that.

ToolStart: LDA #ToolROM : STA ROMBank : JSR ToolDispatch

ToolEnd: LDA #KernelROM : STA ROMBank : RTS

ToolDispatch: JMP ($C000,X)

This is 15 bytes of Low RAM per Toolkit ROM, around 25 clocks dispatch, with the "JSR ToolDispatch" patched to 12 bytes after the starting address when initialized. X is simply set with one more than the low byte of the jump table address, since the address in the JMP in the Jump Table works as a vector for JMP ($C000,X).  Or else the ToolDispatch is a fixed routine at $7FFD, the trampoline is fully relocatable, and the GoldenRAM footprint is 12*(#ToolBoxes)+3.

This allows code that is using the ToolBox to run with the Toolbox code in context and make a simple call, to run with the Kernel or another ROM in context and call the ToolBox with a FarCall, or to run with the Kernel in context and call the ToolBox with the lower overhead Trampoline above.

Y is free for calls with a mutable number of parameters to indicate how many zero page R0-R15 slots are used for parameters.

Post Reply