-- Inline.mesa  (last edited by: Levin on August 24, 1982 4:26 pm)

DIRECTORY
  Environment USING [Comparison, LongNumber],
  Mopcodes USING [
    zAND, zBLT, zBLTL, zDCOMP, zDUCOMP, zDIV, zINC, zLDIV, zLIN1, zMUL, zOR,
    zPUSH, zSHIFT, zXOR];

Inline: DEFINITIONS =
  BEGIN OPEN Mopcodes;

  -- Everything in this interface except COPY, LongCOPY, and PUSH is SAFE.
  
  LongCARDINAL: TYPE = LONG CARDINAL;

  LongNumber: TYPE = Environment.LongNumber;

  COPY: PROC [from: POINTER, nwords: CARDINAL, to: POINTER] = MACHINE CODE
    {zBLT};

  LongCOPY: PROC [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
    MACHINE CODE {zBLTL};

  DIVMOD: SAFE PROC [num, den: CARDINAL] RETURNS [quotient, remainder: CARDINAL] =
    TRUSTED MACHINE CODE {zDIV; zPUSH};

  PUSH: PROC RETURNS [WORD] = MACHINE CODE {zPUSH};

  LDIVMOD: SAFE PROC [numlow: WORD, numhigh: CARDINAL, den: CARDINAL]
    RETURNS [quotient, remainder: CARDINAL] = TRUSTED MACHINE CODE {zLDIV; zPUSH};

  LongMult: SAFE PROC [CARDINAL, CARDINAL] RETURNS [product: LONG CARDINAL] =
    TRUSTED MACHINE CODE {zMUL; zPUSH};

  LongDiv: SAFE PROC [num: LONG CARDINAL, den: CARDINAL] RETURNS [CARDINAL] =
    TRUSTED MACHINE CODE {zLDIV};

  LongDivMod: SAFE PROC [num: LONG CARDINAL, den: CARDINAL]
    RETURNS [quotient, remainder: CARDINAL] = TRUSTED MACHINE CODE {zLDIV; zPUSH};


  BitOp: TYPE = SAFE PROC [UNSPECIFIED, UNSPECIFIED] RETURNS [UNSPECIFIED];

  BITAND: BitOp = TRUSTED MACHINE CODE {zAND};

  BITOR: BitOp = TRUSTED MACHINE CODE {zOR};

  BITXOR: BitOp = TRUSTED MACHINE CODE {zXOR};

  BITNOT: SAFE PROC [UNSPECIFIED] RETURNS [UNSPECIFIED] = TRUSTED MACHINE CODE
    {zLIN1; zXOR};

  BITSHIFT: SAFE PROC [value: UNSPECIFIED, count: INTEGER] RETURNS [UNSPECIFIED] =
    TRUSTED MACHINE CODE {zSHIFT};


  LowHalf: SAFE PROC [u: LONG UNSPECIFIED] RETURNS [UNSPECIFIED] = TRUSTED INLINE
    {RETURN[LOOPHOLE[u, LongNumber].lowbits]};

  HighHalf: SAFE PROC [u: LONG UNSPECIFIED] RETURNS [UNSPECIFIED] = TRUSTED INLINE
    {RETURN[LOOPHOLE[u, LongNumber].highbits]};

  BytePair: TYPE = MACHINE DEPENDENT RECORD [high, low: [0..377B]];

  LowByte: SAFE PROC [u: UNSPECIFIED] RETURNS [UNSPECIFIED] = TRUSTED INLINE
    {RETURN[LOOPHOLE[u, BytePair].low]};

  HighByte: SAFE PROC [u: UNSPECIFIED] RETURNS [UNSPECIFIED] = TRUSTED INLINE
    {RETURN[LOOPHOLE[u, BytePair].high]};


  Comparison: TYPE = Environment.Comparison;

  CompareLC, CompareCard: SAFE PROC [a, b: LONG CARDINAL]
    RETURNS [Comparison] = TRUSTED MACHINE CODE
    {zDUCOMP; zINC};

  CompareINT: SAFE PROC [a, b: INT] RETURNS [Comparison] = TRUSTED MACHINE CODE
    {zDCOMP; zINC};

  END.


LOG
Time: May 22, 1979  4:47 PM	By: Lauer	Action: Created file by renaming Mesa>System>InlineDefs.mesa
Time: June 7, 1979  5:46 PM	By: McJones	Action: Fixed shift count in HighByte
Time: January 25, 1980  4:01 PM	By: Forrest	Action: Equated Long number to Env.longNumber
Time: January 27, 1981  5:33 PM	By: Johnsson	Action: Made High/LowMumble be INLINE instead of MACHINE CODE.
Time: August 24, 1982 4:26 pm	By: Levin	Action: Make appropriate things SAFE.
  Add CompareLC and CompareINT.