On 2023-08-24 2:06 a.m., Jerry Penner wrote:
Colin Leroy-Mira <[email protected]> writes:
The P8 tech-ref states:
----------------------------------------
SYSCALL JSR MLI ;Call Command Dispatcher
DB CMDNUM ;This determines which call is being made
DW CMDLIST ;A two-byte pointer to the parameter list
BNE ERROR ;Error if nonzero
Upon completion of the call, the MLI returns to the address of the
JSR plus 3 (in the above example, the BNE statement); the call
number and parameter list pointer are skipped. ----------------------------------------
Where the CPU returns to is 6 bytes past the label SYSCALL, which is the location of the "BNE ERROR" instruction.
I think I always read and understood the book the way I think Oliver
does, but I think the book's address arithmetic is wrong, looking at it
now.
As far as I remember my 6502 assembly, when you do a JSR, the processor
has already read the JSR byte and the two byte address so the PC is
pointing at the DB CMDNUM statement and that is what is pushed on the
stack. The MLI pulls that address off the stack, adds 3 to it, pushes
it back on the stack and does an RTS so that the BNE ERROR statement
will get executed.
In other words, the SYSCALL is the address of the JSR but it isn't the
address that gets pushed onto the stack when the JSR is executed.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)