home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1990-06-14 | 4.1 KB | 90 lines | [TEXT/PMED] |
- DEFINITION MODULE MacBase; (* Franz Kronseder,ETHZ, 31.05.85 *)
- (* last modified 13.08.85 fxk *)
-
- (* This a lowest level MODULE, allowing MODULA-2 programs created by *)
- (* the 5-Pass-Compiler to run on the Apple Macintosh , *)
- (* and use the OS-routines and ToolBox-Routines in the ROM *)
-
- (* Executable Modula-2 program code is output by the Modula linker *)
- (* and stored in the data-fork of a file named <modulename>.LOD *)
- (* A reloction loader, implemented as a Macintosh Application in *)
- (* native Lisa-Pascal places the code into a segment of the application *)
- (* heap and performs a JSR to the entrypoint of the MODULA-Program. *)
-
- (* The Pascal Loader and the Modula program exchange information about *)
- (* the memory layout and CPU registers in the RootRecord data structure. *)
- (* MacBase offers several trap procedures for accessing the ROM routines *)
- (* via the Line 1010 unimplemented instruction trap of the 68000 CPU. *)
- (*-----------------------------------------------------------------------*)
- FROM SYSTEM IMPORT ADDRESS;
- EXPORT QUALIFIED MacNIL,
- RootRecType, RootRecord,
- ExitToShell,ErrorProc,TellError,
- StrPtr,LongInt,LongWord,Byte,OsType,Point,
- OsErr,Handle,
- PTRAP,PTRAP1,PTRAP2,trapnr,traparg,
- inlineTrap,SyncCoreTrap,AsyncCoreTrap,PackageTrap,
- adjCHAR ,adjPoint;
-
- TYPE
- StrPtr = ADDRESS; (* pointer to a pascal string *)
- LongInt = ADDRESS; (* 32 bit *)
- LongWord = ADDRESS;
- Handle = POINTER TO ADDRESS;
- OsErr = INTEGER;
- Byte = CHAR; (* 8 bit *)
- OsType = ARRAY[0..3] OF CHAR;
- Point = RECORD v:INTEGER; (* vertical *)
- h:INTEGER; (* horizontal *)
- END;
- RootRecType = RECORD
- LoadKey : CARDINAL;
- Layer0Base: ADDRESS;
- Layer0Code: ADDRESS;
- Layer0Top : ADDRESS;
- StackLimit : ADDRESS; (* lower limit, first address not in stack *)
- PascalA5Register : ADDRESS; (* SYSTEMX saves environment *)
- PascalA6Register : ADDRESS; (* for return to rootloader *)
- PascalA7Register : ADDRESS;
- patch1,patch2,patch3 : ADDRESS; (* reserve pointers *)
- LoadfName : ARRAY [0..63] OF CHAR;
- END;
-
- (* The above record is initialized by SYSTEMX. The same type is declared in *)
- (* the Pascal Loader M2EXEC and passed to SYSTEMX at program start time. *)
- (* Both the Pascal and the Modula RootRecord must have the same memory layout *)
-
- TYPE ErrorProc = PROCEDURE(StrPtr,BOOLEAN);
-
- VAR RootRecord : RootRecType; (* initialized by SYSTEMX *)
- MacNIL : ADDRESS; (* NIL constant different in Pascal *)
- (* MacNIL=00000000h; ModulaNIL=0FFFFFFFFh *)
- TellError: ErrorProc;
-
- VAR trapnr :CARDINAL;traparg:CARDINAL; (* for PTRAP1 *)
- (* here are the currently implemented traps *)
- PROCEDURE PTRAP; (* for QuickDraw, EventMgr *)
- PROCEDURE PTRAP1; (* for SFPackage *)
- PROCEDURE PTRAP2; (* for the FileSystem Core Routine Traps *)
- (* for interfacing with the 1010-Emulator-Traps to the Macintosh Operating
- System . The MODULA-Routine that calls PTrap needs to have the same
- parameterlist as the corresponding Pascal-Procedure in the MacOS expects.
- Store the trapnumber 0AxxxH in trapnr *)
-
- (* here are the new, NOT YET implemented traps *)
- PROCEDURE inlineTrap (nr:CARDINAL);
- PROCEDURE SyncCoreTrap (nr:CARDINAL);
- PROCEDURE AsyncCoreTrap(nr:CARDINAL);
- PROCEDURE PackageTrap (nr,sel:CARDINAL);
-
- (* here are ** NOT YET implemented ** operations for adjusting stacked parameters *)
- PROCEDURE adjCHAR (VAR ch:CHAR);
- PROCEDURE adjPoint(VAR Pt:Point);
-
- PROCEDURE ExitToShell;
- (* ExitToShell provides an emergency exit for the application, *)
- (* without touching the stack. It simply launches the Finder, *)
- (* starting it up after freeing the application heap *)
- (* this is implemented! *)
- END MacBase.
-