Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Macintosh Toolbox
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Advent and implementation == === On 68k systems === The original [[Motorola 68000 family]] implementation of the Macintosh operating system executes [[system calls]] using that processor's [[illegal opcode]] [[interrupt|exception handling]] mechanism. Motorola specified that instructions beginning with ''1111'' and ''1010'' would never be used in future 68000 family processors, thus freeing them for use as such by an operating system. Further, they each had their own dedicated [[interrupt vector]], separate from the generic illegal opcode handler. As ''1111'' was reserved for use by ''co''-processors such as the [[68881]] [[floating point unit|FPU]], Apple chose ''1010'' (''A'' in [[hexadecimal]]) as the prefix for operating system calls. Handling illegal instructions is known as ''trapping'', so these special instructions were called ''A-traps''.<ref>{{cite web|url=https://developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html#HEADING170-48 |title=A-Line Instructions |author=Apple Inc. |date=6 July 1996 |archive-url=https://web.archive.org/web/20040702054254/http://developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html#HEADING170-48 |archive-date=2004-07-02}} [http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html#HEADING170-48 Alt URL]</ref> When the processor encounters such an instruction, it transfers control to the operating system, which looks up the appropriate task and performs it. There were two advantages to this mechanism: * It results in compact programs. Only two [[byte]]s are taken by every operating system access, in contrast to four or six when using regular [[jump instruction]]s. * The table used to look up the appropriate function is stored in RAM. Then, even if the underlying code was stored in ROM, it could still be overridden (''[[patch (computing)|patched]]'') by replacing the ROM [[memory address]] with a RAM address. The system was further optimized by allotting some bits of the A-trap instruction to store [[Parameter (computer science)|parameter]]s to the most common functions. For example, [[memory allocation]] is a very common task, so it should be expressed in as few bytes of code as possible. Sometimes the programmer wants to clear the memory block to zeros, so either the allocation function should take a [[Boolean data type|boolean]] parameter, or there should be two allocation functions. To pass a parameter would require an additional two-byte instruction, which would be inefficient. Having two functions would require at least an extra four bytes of RAM used for the address in the function look-up table. The most efficient solution is to map multiple A-traps to the same subroutine, which then uses the A-trap as a parameter. This is true of the most commonly used subroutines. However, the Toolbox was composed of the ''less'' commonly used subroutines. The Toolbox was defined as the set of subroutines which took no parameters within the A-trap, and were indexed from a 1024-entry, 4-kilobyte [[dispatch table]].<ref>{{cite web |url=https://developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html |title=About the Trap Manager |author=Apple Inc. |date=6 July 1996 |archive-url=https://web.archive.org/web/20040702054254/http://developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html |archive-date=2004-07-02}} [http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/OSUtilities/OSUtilities-170.html Alt URL]</ref> (Machines shipped with less than one megabyte of RAM use a single table of 512 entries, which corresponds to the 256-entry OS dispatch table of later ROM revisions.<ref name=macalmanac>{{cite web |url=http://www.mac.linux-m68k.org/devel/macalmanac.php |website=Linux/m68k for Macintosh |title=Mac Alamanac II |first=James H. |last=Olson |date=4 September 1997}}</ref>) === On PowerPC systems === In 1994, Apple released Macintoshes using the [[PowerPC]] architecture, which lacked hardware support for the A-trap mechanism available on 68k systems. Because of their use in applying software patches, however, the dispatch tables were retained. The API library code underlying any Toolbox routine then does nothing except reference the dispatch table. The dispatch table linked only to emulated 68000 family code. Toolbox functions implemented in native PowerPC code have to first disable the emulator using the Mixed Mode Manager. For the sake of uniformity and extensibility, new function entries even continued to be added to the Toolbox after the PowerPC transition. An alternative mechanism did exist, however, in the Code Fragment Manager, which was used to load and dynamically link native PowerPC programs. The PowerPC system call facility, analogous to the A-trap mechanism, was used to interface with the [[Mac OS nanokernel]], which offered few services directly useful to applications.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)