Whenever I've executed code into RAM, I've tried to make sure it doesn't depend on location in any way, so it could be copied to any location and work just the same. That way you don't have to worry about where you load it from, and you don't have to pay attention to how you structure your ROM. It should just be as simple as having no subroutines within your RAM subroutine.
If you want to execute code copied to a particular location, you can use the offset directly:
For your example, you might even use something like:
to adjust for the layout of the memory map, but in that case you would have to ensure that the destination address is the same as the assembled address if the code isn't relocatable.
I'd be happy just copying the whole routine and calling it directly, assuming it's just one routine. You can also use variables and arithmetic operations to achieve some level of relativity. There might be better ways however, and there can be room for a lot of creativity depending on your use case. If you're using nested subroutines or a vector pointing to RAM then things might get a bit tricky.
One semi-related tip is that you can get a small speed boost by enabling the fast ROM access speed ($420D.0) and jumping to a fast bank. Something like:
Code: Select all
slow: ; bank $00
jml $800000 + fast
fast: ; bank $80
Which can be useful to have in interrupt handlers.