DEFINITION MODULE Object;

FROM SYSTEM IMPORT WORD, ADDRESS;
FROM SimpleStks IMPORT Stack;
FROM items IMPORT GlobalLabel;
EXPORT QUALIFIED
    ObjCodeBytes, ObjCodeAddress,
    AllocateCodeBuffer,
    LabelUseType, ExtrnType, ObjPtr, UseOfLabel, 
    BackwardBranch, label, Extrn,
    InstructionEmit, LongEmit, Emit,
    StartObjectModule, EndObjectModule,
    Signed16Bit, Signed8Bit, ShiftLeft,
    DefineRangeCheckLabel, RangeCheckBranchDisp,
    BranchStatisticsWanted,
    ExtrnUNIX, ExtrnNamedCall, ExtrnGlCall,
    Patch,
    (*   For Binary Output  *)

    RelocStack, RelocCount, ExtrnMBStacks, ExtrnMBCounts,
    ExtrnMOStacks, ExtrnMOCounts, ExtrnMPStacks, ExtrnMPCounts,
    ExtrnOSStacks, ExtrnOSCounts, OSProcNames, OSNAME,MaxNStProcs;

CONST
    LotsOfImports = 200;
    MaxNStProcs = 50;

TYPE
    LabelUseType    = (Abs32Bit, Disp16BitInBranch, DispInBranch,
                        Disp8BitInBranch, Disp8BitInPCWithIndex, QuickBSR);
    ExtrnType       = (OtherModuleBase, OtherModuleOffset, 
                                    OtherModuleProc);
    OSNAME = POINTER TO ARRAY [0..79] OF CHAR;

VAR
    RelocStack : Stack;
    RelocCount : CARDINAL;
VAR
    ExtrnMBStacks : POINTER TO ARRAY [0..LotsOfImports] OF Stack;
    ExtrnMBCounts : POINTER TO ARRAY [0..LotsOfImports] OF CARDINAL;

VAR OSProcNames: ARRAY [0 .. MaxNStProcs] OF OSNAME;

    ExtrnMOStacks : POINTER TO ARRAY [0..LotsOfImports] OF Stack;
    ExtrnMOCounts : POINTER TO ARRAY [0..LotsOfImports] OF CARDINAL;
    
    ExtrnMPStacks : POINTER TO ARRAY [0..LotsOfImports] OF Stack;
    ExtrnMPCounts : POINTER TO ARRAY [0..LotsOfImports] OF CARDINAL;
    
    ExtrnOSStacks : ARRAY [0 .. MaxNStProcs] OF Stack;
    ExtrnOSCounts : ARRAY [0 .. MaxNStProcs] OF CARDINAL;

VAR ObjPtr : CARDINAL;
VAR BranchStatisticsWanted : BOOLEAN;

PROCEDURE ObjCodeBytes () : CARDINAL;
PROCEDURE ObjCodeAddress () : ADDRESS;
PROCEDURE AllocateCodeBuffer (bytes: CARDINAL);
PROCEDURE UseOfLabel (label, posn : CARDINAL; TypeOfUse : LabelUseType);
PROCEDURE BackwardBranch (label : CARDINAL; VAR short : BOOLEAN) : BOOLEAN;
PROCEDURE label (lab : CARDINAL);
PROCEDURE Extrn (type : ExtrnType; datum1, datum2 : WORD);
PROCEDURE InstructionEmit (b : BITSET);
PROCEDURE LongEmit (b : BITSET);
PROCEDURE Emit (b : BITSET);
PROCEDURE StartObjectModule;
PROCEDURE EndObjectModule;
PROCEDURE Signed16Bit (i : INTEGER) : BITSET;
PROCEDURE Signed8Bit (i : INTEGER) : BITSET;
PROCEDURE ShiftLeft (b : BITSET; by : CARDINAL) : BITSET;
PROCEDURE DefineRangeCheckLabel;
PROCEDURE RangeCheckBranchDisp;
PROCEDURE ExtrnUNIX (Call : CARDINAL);
PROCEDURE ExtrnNamedCall (CallName : ARRAY OF CHAR);
PROCEDURE ExtrnGlCall (sub : GlobalLabel);
PROCEDURE Patch (offset : CARDINAL; b : BITSET);
END Object.




