Path: utzoo!attcan!uunet!husc6!bloom-beacon!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: Re: MemTop and MultiFinder Message-ID: <8991@dartvax.Dartmouth.EDU> Date: 24 Jun 88 02:41:52 GMT References: <231@hodge.UUCP> <730037@hpcilzb.HP.COM> Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Dartmouth College, Hanover, NH Lines: 47 In article <730037@hpcilzb.HP.COM> tedj@hpcilzb.HP.COM (Ted Johnson) writes: > >>Here's the call as a Pascal inline: >> >>FUNCTION MFMemTop: LongInt; INLINE $3F3C,$0016,$A88F; > >Do any of you LSC gurus out there know how to convert this to LSC? > >-Ted long MFMemTop() { asm{ clr.l -(a7) ; Make room for return value. move.w #0x0016,-(a7) ; Push routine selector. dc.w 0xa88f ; JugglerDispatch move.l (a7)+,d0 ; Pop result into d0 } } The process I used to determine this may be of interest: Get into MacsBug >dh 3f3c0016 000000: 3F3C0016 MOVE.W #$0016,-(A7) That means the Trap wants a 0x0016, presumably as a routine selector. Since the function is declared as a Pascal function, we have to make room for the return value on the stack, then we pass it the selector. Call the trap, pop the result into d0, and we are done. This routine produces seemingly correct results on both machines I have tried it on. Flame section: Did the originator of the MPW Pascal INLINE code it first as shown, or did he use an assembler to determine the instructions to use? Either way, at some point he had to use an assembler or a Motorola handbook to find out that "move.w,-(a7)" translates to "$3F3C ." I suspect that most of us would rather have the assembly code in addition to the hex code. In fact, I make the following suggestion: EVEN THOUGH THIS IS A PROGRAMMER'S NEWSGROUP, I FEEL THAT POSTING CODE IN HEX IS NOT THE LEAST BIT INSTRUCTIVE. PLEASE POST THE ASSEMBLY SOURCE IN ADDITION TO THE INLINE DECLARATION, SO WE CAN SEE WHAT YOU ARE DOING. End flame section.