Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 8 - Trap Manager / Trap Manager Reference
Routines / Accessing Addresses From the Trap Dispatch Tables


NGetTrapAddress

You can use the NGetTrapAddress function to retrieve the address of either an Operating System routine or a Toolbox routine.

FUNCTION NGetTrapAddress (trapNum: Integer; tTyp: TrapType)
                           :LongInt;
trapNum
A-line instruction or a trap number. If you specify an A-line instruction, the function extracts the trap number for you.
tTyp
The trap type. If you supply the tTyp parameter with the constant OSTrap, the NGetTrapAddress function retrieves the address from the Operating System trap dispatch table. If you supply tTyp parameter with the constant ToolTrap, the NGetTrapAddress function retrieves the address from the Toolbox trap dispatch table.
DESCRIPTION
The NGetTrapAddress function returns the address of the system software routine specified by the tTyp and trapNum parameters. If tTyp is OSTrap, the NGetTrapAddress function retrieves the address from the Operating System trap dispatch table. If tTyp is ToolTrap, the NGetTrapAddress function retrieves the address from the Toolbox trap dispatch table. If the desired system software routine is not supported on the installed system software, NGetTrapAddress returns the address of the Unimplemented procedure. The trapNum parameter should contain a trap number in bits 0-7 if tTyp is OSTrap, and in bits 0-9 if tTyp is ToolTrap.

The trapNum parameter may have any word value; its irrelevant high-order bits are masked according to the value of the tTyp parameter.

Note
If the system software routine has a come-from patch, the NGetTrapAddress function returns the address of the routine immediately following the come-from patch.
ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for the _GetTrapAddress macro are
Registers on entry
D0An A-line trap word
Registers on exit
A0Address of next routine in the daisy chain (a system software routine or a patch)

When calling the _GetTrapAddress macro, you set bit 9 of the A-line instruction to indicate a "new" system; that is, any version since the Macintosh Plus or Macintosh 512K. You use bit 10 to indicate whether the trap in question is a Toolbox routine (by setting bit 10 to 1) or an Operating System routine (by setting bit 10 to 0). Macintosh development environments provide the modifier words newTool and newOS to be used as arguments in the _GetTrapAddress macro.

To obtain the address of a Toolbox trap whose number is in register D0, you use the macro

_GetTrapAddress newTool
This is equivalent to calling NGetTrapAddress (trapNum, newTool). The trapNum parameter is the A-line trap word placed in register D0 for the assembly-language call. Similarly, to obtain the address of an Operating System routine whose A-line trap word is in register D0, you use the macro

_GetTrapAddress newOS
This is equivalent to calling NGetTrapAddress(trapNum, newOS).

SEE ALSO
For information about the Unimplemented procedure, see page 8-29. For information about the NSetTrapAddress function, see page 8-30.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996