Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcsun!sunic!draken!d88-jwa From: d88-jwa@nada.kth.se (Jon Watte) Newsgroups: comp.sys.mac.programmer Subject: Re: patching SetPort() Message-ID: <2975@draken.nada.kth.se> Date: 19 Feb 90 00:41:16 GMT References: <3991@hub.UUCP> Reply-To: d88-jwa@nada.kth.se (Jon W{tte) Organization: Royal Institute of Technology, Stockholm, Sweden Lines: 50 >From article <>, by jjoshua@topaz.rutgers.edu (Jon Joshua): >> Question: Could someone please shed some light on what might be >> happening? Why only under MF and not finder. I tried booting with 0 >> INITs/CDEVs etc. and the same thing happened. In article <3991@hub.UUCP> 6500stom@hub.UUCP (Josh Pritikin) writes: >I think its better to do it this way: > asm { > movem a0/a1/d0,-(sp) ;save the reg that you use > bra.s @start ;Jump over storage > tAddr: dc.l 0 ;Save SetPort trap addr here > start: jsr main ;Do neat stuff > movem (sp)+,a0/a1/d0 > move.l @tAddr,-(sp) ;Load orig SetPort trap addr > rts ;Outa' here > } Why bother ? The THINK C linker automagically fixes this for you. Sort of. When compiling code resources, it sets up storage for globals, and has a jump instruction at relative location 0 within the code segment to the functino named main() (This is _always_ the main entry point) You should really do something like: long savedAddress; main() { asm { movem a0/a1/d0,-(sp) } do_neat_stuff(); asm { movem (sp)+,a0/a1/d0 unlk a6 move.l savedAddress,-(sp) rts } } This is my guess... h+ -- --- Stay alert ! - Trust no one ! - Keep your laser handy ! --- h+@nada.kth.se == h+@proxxi.se == Jon Watte longer .sig available on request