IntCodeTarget.mesa
Copyright Ó 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) September 18, 1987 5:59:39 pm PDT
JKF July 27, 1988 8:12:07 am PDT
Willie-s, September 23, 1991 5:57 pm PDT
DIRECTORY
Basics32 USING [BITLSHIFT, BITRSHIFT],
Rope USING [ROPE];
IntCodeTarget: CEDAR DEFINITIONS
IMPORTS Basics32
= BEGIN OPEN Rope;
This file has definitions that allow us to be parameterized according to the target. Most of the variables are not constants to allow us to share more code without recompilation.
Machine description
name: READONLY ROPE;
Gives a human-readable name for the target machine. Useful for messages.
Addressing units
bitsPerAU: READONLY NAT;
logBitsPerAU: READONLY NAT;
bytesPerAU: READONLY NAT;
logBytesPerAU: READONLY NAT;
Bit order
bitOrder: READONLY BitOrder;
BitOrder: TYPE = {msBit, lsBit};
Arguments & returns
maxBitsArgumentRecord: READONLY NAT;
gives the # of bits for the largest "fast" argument record
minBitsPerArgument: READONLY NAT;
logMinBitsPerArgument: READONLY NAT;
Gives the minimum # of bits for an argument
(to get the bits for an argument, round up & shift by logMinBitsPerArgument)
maxBitsReturnRecord: READONLY NAT;
gives the # of bits for the largest "fast" return record
minBitsPerReturn: READONLY NAT;
logMinBitsPerReturn: READONLY NAT;
Gives the minimum # of bits for an return value
Global frame
bitsPerGlobal: READONLY NAT;
logBitsPerGlobal: READONLY NAT;
Gives the minimum # of bits for an global variable
firstGlobalOffset: READONLY NAT;
First offset usable for global variables (in bits)
directGlobals: READONLY BOOL;
TRUE => target supports direct use of global variables
FALSE => target requires global frame pointer
Local frame & stack
lastRegister: READONLY NAT;
Gives # of registers to be used for local variables
lastStack: READONLY NAT;
Gives last stack location to be used for passing arguments
bitsPerLocal: READONLY NAT;
logBitsPerLocal: READONLY NAT;
Gives the minimum # of bits for an local variable
bitsPerLink: READONLY NAT;
logBitsPerLink: READONLY NAT;
Gives the minimum # of bits for a link
(uniform for static link, global link, & frame extension if any).
Utility routines
ToUnits: PROC [bits: INT, minBits: NAT, logMinBits: NAT] RETURNS [INT] = INLINE {
SELECT bits FROM
<= 0 => RETURN [0];
<= minBits => RETURN [1];
ENDCASE => RETURN [Basics32.BITRSHIFT[bits+minBits-1, logMinBits]];
};
ToBits: PROC [units: INT, logBitsPerUnit: NAT] RETURNS [INT] = INLINE {
SELECT units FROM
<= 0 => RETURN [0];
ENDCASE => RETURN [Basics32.BITLSHIFT[units, logBitsPerUnit]];
};
END.