-- Utilities.mesa (last edited by Forrest on July 17, 1980 7:12 PM)
DIRECTORY
Environment USING [Long, PageNumber, wordsPerPage],
Inline USING [LongMult],
Mopcodes USING [zLI4, zRFSL, zSHIFT, zWFSL],
PrincOps USING [FieldDescriptor];
Utilities: DEFINITIONS IMPORTS Inline =
BEGIN
LongMove: PROC [pSource: LONG POINTER, size: CARDINAL, pSink: LONG POINTER];
-- Moves the contents of the size words starting at pSource to the size words starting at pSink.
-- Unlike InlineDefs.LongCOPY, overlapping blocks do not cause replication of source words.
-- Ideally this too would be implemented as a MACHINE CODE
ShortCARDINAL: PROC [cc: LONG UNSPECIFIED] RETURNS [CARDINAL] =
-- Assumes cc IN CARDINAL
INLINE { RETURN[LOOPHOLE[cc, Environment.Long].lowbits] };
-- Inline copies of Page<=>LongPointer for people not in positions to make procedure calls
LongPointerFromPage: PROC [page: Environment.PageNumber] RETURNS [LONG POINTER] =
INLINE { RETURN[LOOPHOLE[Inline.LongMult[page, Environment.wordsPerPage]]] };
PageFromLongPointer: PROC [lp: LONG POINTER] RETURNS [page: Environment.PageNumber] =
INLINE BEGIN OPEN LOOPHOLE[lp, num Environment.Long];
RETURN[highbits*256+lowbits/256]
END;
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Packed Bit Array operations:
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Note: packed bit arrays are currently limited to a maximum of 4096 bits.
Bit: TYPE = CARDINAL[0..1];
BitIndex: TYPE = CARDINAL[0..4096); -- (restriction of current implementation)
BitArray: TYPE = UNSPECIFIED; -- TIGHTLY PACKED ARRAY (0..0) OF Bit (no array descriptor)
BitGet: PROC [lp: LONG POINTER TO BitArray, bitIndex: BitIndex] RETURNS [Bit] =
INLINE { RETURN[BitGetFromBitDesc[lp, BitDescFromBitIndex[bitIndex]]] };
BitPut: PROC [bit: Bit, lp: LONG POINTER TO BitArray, bitIndex: BitIndex] =
INLINE { BitPutFromBitDesc[bit, lp, BitDescFromBitIndex[bitIndex]] };
-- Private to implementation:
BitDescriptor: PRIVATE TYPE = PrincOps.FieldDescriptor;
BitGetFromBitDesc: PRIVATE PROC [lp: LONG POINTER TO BitArray, bd: BitDescriptor] RETURNS [Bit] =
MACHINE CODE BEGIN Mopcodes.zRFSL END;
BitPutFromBitDesc: PRIVATE PROC [bit: Bit, lp: LONG POINTER TO BitArray, bd: BitDescriptor] =
MACHINE CODE BEGIN Mopcodes.zWFSL END;
-- shifts left 4 bits (therefore, bitIndex must be < 4096).
BitDescFromBitIndex: PRIVATE PROC [bitIndex: BitIndex] RETURNS [BitDescriptor] =
MACHINE CODE BEGIN Mopcodes.zLI4; Mopcodes.zSHIFT END;
END.
LOG
Time: April 24, 1980 4:52 PMBy: ForrestAction: Trimmed log Amargosa. Converted to use PrincOps.
Time: April 24, 1980 4:52 PMBy: ForrestAction: Made Page<=>LongPointer INLINE.