Those dirty, DIRTY Mac OS ROMs ;-)
julianskidmore at yahoo.com
Wed May 6 17:02:07 CDT 2009
> Then of course there were those programmers that thought they were
> clever, using the top 8 bits to store flags in pointers, etc
Ethan Dicks wrote:
> I remember reading a warning against such practices the original Mac
> system manuals (the "hernia manuals"), but faced with 128K of RAM,
> early programmers did not universally heed the warning.
Ironically, those early programmers were - the geniuses who developed the
Mac OS! It was the Macintosh heap manager which stored flags in the upper
byte, that's why the ROMs themselves were dirty.
As described in Inside Macintosh Volume 2, Master Heap pointers use the
top 3 bits of an address to hold flags: Lock, Purge, Resource. The next
5 are unused. The documentation tells you to mask a heap pointer with
0xffffff to get an address or mask with the specific flag bytes to find
out their flags.
In System 7 they introduced StripAddress which does &0xffffff in a 24-bit
startup mode or does nothing in 32-bit mode. They also provided the
functions Translate24To32 and HGetState/ HSetState to manipulate the
flags that used to be in the top byte.
-cheers from julz @P
More information about the cctech