chrisj@cup.portal.com (10/08/88)
Macintosh Tech Note 200, "MPW 2.0.2 Bugs", page 14, shows the following
"corrected" code for the SlotVRemove glue:
;----------------------------------------------------------------------
;FUNCTION SlotVRemove(vblTaskPtr: QElemPtr; theSlot: Integer): OSErr;
;----------------------------------------------------------------------
SlotVRemove PROC EXPORT
MOVEA.L (SP)+,A1 ;Get the return address
;===> MOVEA.L (SP)+,A0 ;==OOPS, popped args in wrong order!
MOVE.W (SP)+,D0 ;The slot number
MOVEA.L (SP)+,A0 ;The VBL task ptr
MOVE.L A1,-(SP) ;Put the return address back
_SlotVRemove ;Call the register based trap
MOVE.W D0,(SP) ;Set the result code
JMP (A1) ;And go home
Unfortunately, the correction itself requires a correction. The MOVE
preceeding the trap macro saves the return address on the stack, the
MOVE following the trap stores the result code on top of the high word
of the saved return address, and the JMP returns to the caller with 4
more bytes left on the stack than it should. Since IM I-94 says that
the trap dispatcher saves and restores A1 around register-based traps,
it appears that we can just get rid of the instruction right before the
trap macro:
...
;===> MOVE.L A1,-(SP) ;unnecessary to save A1
_SlotVRemove ;Call the register based trap
MOVE.W D0,(SP) ;Set the result code
JMP (A1) ;And go home
An alternative would be to replicate the first instruction of the
procedure, placing the duplicate immediately after the trap macro.
...
MOVE.L A1,-(SP) ;Put the return address back
_SlotVRemove ;Call the register based trap
MOVEA.L (SP)+,A1 ;Get the return address (again)
MOVE.W D0,(SP) ;Set the result code
JMP (A1) ;And go home
Would one of the Apple folks please confirm that the first alternative
shown above is the right way to glue to SlotVRemove? Thank you.
Christopher T. Jewell chrisj@cup.portal.com sun!cup.portal.com!chrisj
"I figure the people who close zoos at night know what they're doing."
Mike Royko (on night baseball at Wrigley Field)darin@Apple.COM (Darin Adler) (10/17/88)
In article <9852@cup.portal.com> chrisj@cup.portal.com writes: > ... it appears that we can just get rid of the instruction right before the > trap macro: > ... > ;===> MOVE.L A1,-(SP) ;unnecessary to save A1 > _SlotVRemove ;Call the register based trap > MOVE.W D0,(SP) ;Set the result code > JMP (A1) ;And go home > > Would one of the Apple folks please confirm that the first alternative > shown above is the right way to glue to SlotVRemove? Thank you. Yes. This is the right way to correct the SlotVRemove glue. As a matter of fact, this is exactly what the MPW 3.0 SlotVRemove glue contains, the error is only in the Technical Note. -- Darin Adler AppleLink: Adler4 UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin CSNET: darin@Apple.com