General Compatibility Guidelines
General Compatibility Guidelines How to keep your software from breaking in
the future
Apple makes significant changes to the Macintosh and its operating system
from time to time. To help ensure your software's compatibility with these
changes, Apple has published a set of guidelines that you should follow when
writing software for the Macintosh family of computers. This guideline is
known as Macintosh Technical Note #2. Below is a brief description of the
contents of that Technical Note. Most of these guidelines pertain to
programmers using assembly language, but are still of interest to those using a
high level language like C or Pascal.
Do not depend on 68000 instructions that require the processor
be in supervisor mode.
This includes instructions that modify the contents of the status register
(except the Condition Code Register portion of the status register),
manipulation of the User Stack Pointer and turning interrupts on or off.
Do not use code that executes in response to an exception and
relies on the position of data in the exception's local stack frame.
Exception stack frames vary on different micro processors within the 68000
family. In particular, don't use the TRAP instruction.
Do not use low memory globals that are not documented.
No un documented location below the system heap (0x100 through 0x13FF) is
guaranteed to be available for use in future systems.
Do not make assumptions about the file system that are not
consistent with both the original Macintosh File System and the
Hierarchical File System.
Your application should be compatible with both file systems. The easiest way
to do this is to use the old file system calls as much as possible since the older
calls work with both MFS and HFS.
Do not depend on the system or application heaps starting at
hard-coded addresses.
Do not look through the system's queues directly.
You should avoid examining queue elements directly. Instead use the Operating
System calls to manipulate queue elements.
Do not directly access memory mapped hardware such as the VIA,
the SCC or the IWM.
Use trap calls (via the Disk Driver, Serial Driver, etc.). Some machines
contain a memory management unit (MMU) that may prevent access to
memory-mapped hardware.
Do not assume the location or size of the screen.
The location, size and bit depth of the screen is different in various machines.
You can determine its location and size by examining the QuickDraw global
variable screenBits on machines without Color QuickDraw. On machines
with Color QuickDraw, the DeviceList tells the location, size and bit depth of
each screen, screenBits contains the location and size of the main screen, and
GrayRgn contains a region describing the shape and size of the desktop.
Do not change master pointer flags of relocatable blocks directly
with BSET or BCLR instructions.
Under A/UX and other Macintosh operating systems, all 32 bits may be in use
for addressing, with the flag byte moved somewhere else. Use the Memory
Manager calls HPurge, HNoPurge, HLock, HUnlock, HSetRBit,
HClrRBit, HGetState and HSetState to manipulate the master pointer
flags.
Do not use timing sensitive code.
Various Macintoshes run at various clock speeds. Use Delay or TickCount
for timing.
Use ASCII codes rather than keyboard key codes.
The various keyboards are slightly different. For textual input, read ASCII
codes rather than key codes.
Do not rely on the format of packed addresses in the trap
dispatch table.
The trap dispatch table is different on various machines. Apple does not
guarantee that the trap table format will not change in the future. Use
GetTrapAddress and SetTrapAddress to manipulate the trap dispatch
table.