Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!imagen!atari!portal!cup.portal.com!chrisj From: chrisj@cup.portal.com Newsgroups: comp.sys.mac.programmer Subject: TN200 SlotVRemove Is Wrong Message-ID: <9852@cup.portal.com> Date: 8 Oct 88 04:58:28 GMT Organization: The Portal System (TM) Lines: 45 XPortal-User-Id: 1.1001.2041 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)