Collen wrote:
thing is, you need to "JSL put_str" the thing...how can you do this in 6502 emulation mode
The short answer is you don't. Just as you use
RTS to return from a subroutine called with
JSR, you use
RTL to return from a subroutine called with
JSL.
The fundamental difference is
JSL pushes the current program bank (the contents of
PB) along with the return address (minus one), after which
PB is loaded with bits 16-23 of the subroutine's address.
RTL pulls the return address and the bank byte that was pushed by
JSL.
put_str has
RTL as the return instruction, which means your subroutine call
must use
JSL to match the
RTL. If you attempt to call
put_str with
JSR the
RTL return instruction will fail because it will pull a garbage byte instead of a real bank byte. The result will be a bogus address, sending the MPU off to uncharted waters. Also, the stack will become unbalanced and if the bogus address pulled by the MPU doesn't crash the machine, the jacked-up stack will.
Succinctly stated,
JSR/RTS pushes/pulls two bytes to/from the stack.
JSL/RTL pushes/pulls three bytes.
Of course, all this begs the question of why you would be running in emulation mode. There's a good chance the BIOS primitives were written with the expectation of the MPU running in native mode. I can foresee all sorts of bad things happening in emulation mode.