Article View: net.micro.mac
Article #7213Re: ETH Modula2 Single Pass (how to access the tool-box)
From: bobc
Date: Thu, 09 Oct 1986 17:49
Date: Thu, 09 Oct 1986 17:49
70 lines
3078 bytes
3078 bytes
In article <809@gould9.UUCP> joel@gould9.UUCP (Joel West) writes:
>This only works for stack-based calls, which are normally limited
>to the toolbox. For example, if MacMETH doesn't provide assembler,
>and doesn't provide direct access to the file manager, device
>manager, and memory manager, you're SOOL.
>--
> Joel West MCI Mail: 282-8879
Actually you don't need a assembler to do OS traps, but some simple
rules are in order. First OS traps require some glue code to adjust
things correctly for example, and the INLINE directive should be used
instead of the "CODE" procedure:
FROM SYSTEM IMPORT ADDRESS,INLINE,SETREG,REG,ADR,WORD;
CONST A0 = 8; D0 = 0;
PROCEDURE OSEventAvail (mask: WORD; VAR theEvent: EventRecord): BOOLEAN;
BEGIN
SETREG(8,ADR(theEvent)); SETREG(0,mask);
CODE(0A030H);
RETURN(VAL(INTEGER,REG(0)) = 0)
END OSEventAvail;
Rule #2 Don't use WITH statements with INLINE traps. Things will
normally work ok if the WITH closes before the TRAP. For example the
following may fail:
IMPLEMENTATION MODULE FileManager;
FROM SYSTEM IMPORT ADR,REG,SETREG,INLINE,WORD;
FROM PascalStrings IMPORT MakePascalString;
FROM MacTypes IMPORT OSErr;
FROM FileTypes IMPORT OSType,ParamBlockRec;
CONST
OpenTrap = 0A000H;
A0 = 8;
D0 = 0;
...
PROCEDURE FSOpen(VAR Name:ARRAY OF CHAR;vRef:INTEGER;VAR ref:INTEGER):OSErr;
VAR PB:ParamBlockRec; Str:ARRAY[0..255] OF CHAR;
BEGIN
WITH PB DO
ioCompletion := NIL; MakePascalString(Name,Str);
PB.ioNamePtr := ADR(Str); PB.ioVRefNum := vRef;
PB.ioVersNum := 0C; PB.ioPermssn := 0C; PB.ioMisc := NIL;
SETREG(A0,ADR(PB)); INLINE(OpenTrap);
ref := ioRefNum; RETURN(ioResult);
END;
END FSOpen;
....
But if it is done like this it will work:
WITH PB DO
ioCompletion := NIL;
...
ioMisc := NIL;
END;
SETREG(A0,ADR(PB)); INLINE(OpenTrap);
ref := ioRefNum;
RETURN(ioResult);
...
Of the things in MacMETH that I want the most are: HFS Search Paths, in
both the Linker and in the Loader for finding object files. But by the
time that they get that done I will not need MacMETH anymore. (Hint:
I am working on a MPW version of Modula-2).
Bob Campbell
Teltone Corporation 18520 - 66th AVE NE
P.O. Box 657 Seattle, WA 98155
Kirkland, WA 98033
{amc,dataio,fluke,hplsla,sunup,uw-beaver}!tikal!bobc
Technical Details
Message-ID:
<513@tikal.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!caip!think!mit-eddie!genrad!decvax!tektronix!uw-beaver!tikal!bobcReferences:
<6@fornax.uucp> <384@ethz.UUCP> <809@gould9.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!columbia!rutgers!caip!think!mit-eddie!genrad!decvax!tektronix!uw-beaver!tikal!bobc From: bobc@tikal.UUCP Newsgroups: net.micro.mac,net.lang.mod2 Subject: Re: ETH Modula2 Single Pass (how to access the tool-box) Message-ID: <513@tikal.UUCP> Date: Thu, 9-Oct-86 13:49:54 EDT Article-I.D.: tikal.513 Posted: Thu Oct 9 13:49:54 1986 Date-Received: Fri, 10-Oct-86 08:49:01 EDT References: <6@fornax.uucp> <384@ethz.UUCP> <809@gould9.UUCP> Reply-To: bobc@tikal.UUCP (Bob Campbell) Distribution: net Organization: Teltone Corp., Kirkland, WA Lines: 70 Keywords: INLINE (MacMETH in general very good but....)