News for hackers. Stuff that matters.
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!

There are no comments on this comment yet.