by flohofwoe · 3y ago · 0 comments
For instance on the KC85/2..4 operating system (CAOS) the equivalent of "puts()" expects the "syscall index" and zero-terminated text to print after the call instruction, e.g.:
CALL 0F003H ; call into generic "syscall" entry
DEFB 23H ; "syscall" identifier
DEFM 'HELLO WORLD!'
DEFW 0D0AH ; newline
DEFB 00 ; end of text
NOP ; execution continues here
The syscall dispatcher would pop the return address from the stack and that way discover the data. Before the syscall returns, a modified return address which points to the first byte after the data is pushed back on the stack.Only downside of this approach was that disassemblers would get terribly confused, unless they had specific knowledge about this CAOS peculiarity.
https://archive.org/details/The_Official_GEOS_Programmers_Re...
addr: _LoadSeg
dc.w segmentNumber
dc.w segmentOffset
The _LoadSeg trap would ensure that 'CODE'(segmentNumber) was loaded from disk and then modify the jump code @addr to become an absolute JMP (0x4ef9 + 32 bits) and then set the PC back to @addr and return from the trap. There was also an _UnloadSeg mechanism that would reverse this!