Inline.mesa (last edited by: Plass on August 31, 1984 10:52:21 am PDT)
Cedar PilotBridge version
Pier, July 2, 1985 3:20:50 pm PDT
Copyright (C) Xerox Corporation 1982. All rights reserved.
DIRECTORY
Basics USING [BITSHIFT, bitsPerWord, BytePair, DivMod, LongDiv, LongDivMod, LongMult, LongNumber],
PrincOpsUtils USING [BITAND, BITNOT, BitOp, BITOR, BITSHIFT, BITXOR, Copy, LongCopy];
Inline: DEFINITIONS IMPORTS Basics, PrincOpsUtils =
BEGIN
LongCARDINAL: TYPE = LONG CARDINAL;
LongNumber: TYPE = Basics.LongNumber;
COPY: PROCEDURE [from: POINTER, nwords: CARDINAL, to: POINTER] = PrincOpsUtils.Copy;
LongCOPY: PROCEDURE [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
PrincOpsUtils.LongCopy;
LongCOPYReverse: PROCEDURE [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] =
INLINE {FOR i: CARDINAL DECREASING IN [0..nwords) DO (to+i)^ ← (from+i)^ ENDLOOP};
DIVMOD: PROCEDURE [num, den: CARDINAL] RETURNS [quotient, remainder: CARDINAL] =
Basics.DivMod;
LDIVMOD: PROCEDURE [numlow: WORD, numhigh: CARDINAL, den: CARDINAL]
RETURNS [quotient, remainder: CARDINAL] =
Basics.LongDivMod;
LongMult: PROCEDURE [CARDINAL, CARDINAL] RETURNS [product: LONG CARDINAL] =
Basics.LongMult;
LongDiv: PROCEDURE [num: LONG CARDINAL, den: CARDINAL] RETURNS [CARDINAL] =
Basics.LongDiv;
LongDivMod: PROCEDURE [num: LONG CARDINAL, den: CARDINAL]
RETURNS [quotient, remainder: CARDINAL] =
Basics.LongDivMod;
BitOp: TYPE = PROCEDURE [UNSPECIFIED, UNSPECIFIED] RETURNS [UNSPECIFIED];
BITAND: BitOp = PrincOpsUtils.BITAND;
BITOR: BitOp = PrincOpsUtils.BITOR;
BITXOR: BitOp = PrincOpsUtils.BITXOR;
BITNOT: PROCEDURE [UNSPECIFIED] RETURNS [UNSPECIFIED] =
PrincOpsUtils.BITNOT;
BITSHIFT: PROCEDURE [value: UNSPECIFIED, count: INTEGER] RETURNS [UNSPECIFIED] =
PrincOpsUtils.BITSHIFT;
BITROTATE: PROCEDURE [value: UNSPECIFIED, count: INTEGER] RETURNS [UNSPECIFIED] =
INLINE {
count ← BITAND[count, Basics.bitsPerWord-1];
RETURN [Basics.BITSHIFT[value, count]+Basics.BITSHIFT[value, Basics.bitsPerWord-count]]
};
LowHalf: PROCEDURE [u: LONG UNSPECIFIED] RETURNS [UNSPECIFIED] = INLINE
BEGIN RETURN[LOOPHOLE[u, LongNumber].lowbits] END;
HighHalf: PROCEDURE [u: LONG UNSPECIFIED] RETURNS [UNSPECIFIED] = INLINE
BEGIN RETURN[LOOPHOLE[u, LongNumber].highbits] END;
BytePair: TYPE = Basics.BytePair;
LowByte: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED] = INLINE
BEGIN RETURN[LOOPHOLE[u, BytePair].low] END;
HighByte: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED] = INLINE
BEGIN RETURN[LOOPHOLE[u, BytePair].high] END;
UDDivMod: PROCEDURE [
num, den: LONG CARDINAL] RETURNS [quotient, remainder: LONG CARDINAL] =
INLINE {quotient ← num/den; remainder ← num MOD den};
SDDivMod: PROCEDURE [
num, den: LONG INTEGER] RETURNS [quotient, remainder: LONG INTEGER] =
INLINE {quotient ← num/den; remainder ← num MOD den};
DBitOp: TYPE = PROCEDURE [
a: LONG UNSPECIFIED, b: LONG UNSPECIFIED] RETURNS [LONG UNSPECIFIED];
Lng: PRIVATE PROCEDURE [lo, hi: UNSPECIFIED] RETURNS [LONG UNSPECIFIED] ~ MACHINE CODE {};
DBITAND: DBitOp = INLINE {RETURN [Lng[lo: BITAND[LowHalf[a], LowHalf[b]], hi: BITAND[HighHalf[a], HighHalf[b]]]]};
DBITOR: DBitOp = INLINE {RETURN [Lng[lo: BITOR[LowHalf[a], LowHalf[b]], hi: BITOR[HighHalf[a], HighHalf[b]]]]};
DBITXOR: DBitOp = INLINE {RETURN [Lng[lo: BITXOR[LowHalf[a], LowHalf[b]], hi: BITXOR[HighHalf[a], HighHalf[b]]]]};
DBITNOT: PROCEDURE [a: LONG UNSPECIFIED] RETURNS [LONG UNSPECIFIED] = INLINE {RETURN [Lng[lo: BITNOT[LowHalf[a]], hi: BITNOT[HighHalf[a]]]]};
DBITSHIFT: PROCEDURE [
value: LONG UNSPECIFIED, count: INTEGER] RETURNS [LONG UNSPECIFIED];
Not really Inline for Cedar
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: 22-Jul-81 12:01:07 By: JGS Action: Added double operations
Time: 30-Mar-83 12:12:57 By: Johnsson Action: Added LongCOPYReverse
Time: August 31, 1984 10:52:31 am PDT By: Plass Action: Created Cedar PilotBridge version from version of 30-Mar-83 12:13:17 PST