Re:i386 Assembly Language trick for storing data in .text
by warpspin on Thursday November 09, 2023 @02:56AM
(#38202282)
Yes. C64 GEOS also used this a lot. They used to call it „inline calls“:
https://archive.org/details/The_Official_GEOS_Programmers_Re...
Re:i386 Assembly Language trick for storing data in .text
by n_plus_1_acc on Thursday November 09, 2023 @05:40AM
(#38203316)
The TI 83 family of calculators with a Z80 also use this.
Re:i386 Assembly Language trick for storing data in .text
by PinguTS on Thursday November 09, 2023 @05:53AM
(#38203416)
Oh, yeah, KC85. We had them in school, when I was in my early teens.
Re:i386 Assembly Language trick for storing data in .text
by jsymolon on Thursday November 09, 2023 @06:47AM
(#38203834)
Apple II, DOS and PRODOS calls do that too.
Re:i386 Assembly Language trick for storing data in .text
by tenebrisalietum on Thursday November 09, 2023 @10:58AM
(#38206639)
The C128 had a KERNAL routine called PRIMM that did that.
Re:i386 Assembly Language trick for storing data in .text
by cancerhacker on Thursday November 09, 2023 @02:50PM
(#38210162)
Classic Mac used this for some toolbox traps as well. Most apps used a jump table at some offset from the A5 register, which looked like:
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!
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.:
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.