Important: The information in this document is obsolete and should not be used for new development.
NGetTrapAddress
You can use theNGetTrapAddressfunction 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
tTypparameter with the constantOSTrap, theNGetTrapAddressfunction retrieves the address from the Operating System trap dispatch table. If you supplytTypparameter with the constantToolTrap, theNGetTrapAddressfunction retrieves the address from the Toolbox trap dispatch table.DESCRIPTION
TheNGetTrapAddressfunction returns the address of the system software routine specified by thetTypandtrapNumparameters. IftTypisOSTrap, theNGetTrapAddressfunction retrieves the address from the Operating System trap dispatch table. IftTypisToolTrap, theNGetTrapAddressfunction retrieves the address from the Toolbox trap dispatch table. If the desired system software routine is not supported on the installed system software,NGetTrapAddressreturns the address of theUnimplementedprocedure. ThetrapNumparameter should contain a trap number in bits 0-7 iftTypisOSTrap, and in bits 0-9 iftTypisToolTrap.The
trapNumparameter may have any word value; its irrelevant high-order bits are masked according to the value of thetTypparameter.
- Note
- If the system software routine has a come-from patch, the
NGetTrapAddressfunction returns the address of the routine immediately following the come-from patch.![]()
ASSEMBLY-LANGUAGE INFORMATION
The registers on entry and exit for the_GetTrapAddressmacro are
Registers on entry D0 An A-line trap word
Registers on exit A0 Address of next routine in the daisy chain (a system software routine or a patch) When calling the
_GetTrapAddressmacro, 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 wordsnewToolandnewOSto be used as arguments in the_GetTrapAddressmacro.To obtain the address of a Toolbox trap whose number is in register D0, you use the macro
_GetTrapAddress newToolThis is equivalent to callingNGetTrapAddress(trapNum, newTool). ThetrapNumparameter 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 newOSThis is equivalent to callingNGetTrapAddress(trapNum, newOS).SEE ALSO
For information about theUnimplementedprocedure, see page 8-29. For information about theNSetTrapAddressfunction, see page 8-30.