Page Numbers: Yes First Page: 36 X: 527 Y: 10.5"
Margins: Binding: 13
Odd Heading: Not-on-first-page
Alto/Mesa Miscellaneous
Even Heading:
Alto/Mesa Miscellaneous
Alto/Mesa Miscellaneous
October 1980
This section describes some miscellaneous facilities in Alto/Mesa.
MiscDefs
Zero: PROCEDURE [p: POINTER, l: CARDINAL];
FOR i IN [0..l) DO (p+i)↑ ← 0.
SetBlock: PROCEDURE [p: POINTER, v: UNSPECIFIED, l: CARDINAL];
FOR i IN [0..l) DO (p+i)↑ ← v.
ByteBlt: PROCEDURE [to, from: POINTER, toByte, fromByte, nBytes: CARDINAL];
Moves nBytes bytes from from[fromByte] to to[toByte]. It uses COPY if the bytes are aligned and BITBLT if they aren’t.
Warning: ByteBlt will not work in the case of overlap.
DAYTIME: PROCEDURE RETURNS [AltoFileDefs.TIME];
Returns the current time in the format maintained by the Alto Operating System and recorded in Alto files. This is not the same format as a TimeDefs.PackedTime.
CurrentTime: PROCEDURE RETURNS [LONG CARDINAL];
Returns the current time. This is the same format as a TimeDefs.PackedTime.
GetNetworkNumber: PROCEDURE RETURNS [CARDINAL];
Returns the number of the network to which the Alto is connected or zero if there is no network or no response from a gateway.
Fine point: this procedure is used by the Compiler and others to generate unique identifiers for output files.
CommandLineCFA: PROCEDURE RETURNS [POINTER TO AltoFileDefs.CFA];
Returns a pointer to the CFA for the point at which the Mesa executive stopped reading the command line (Com.cm). This is valid only when a configuration is started from the command line using Mesa.image. The caller can use the CFA to quickly open a stream on the command line and read any additional commands. The CFA should be updated before returning to the Mesa executive. See the sections on Files and Streams for more information.
CallDebugger: PROCEDURE [STRING];
WorryCallDebugger: PROCEDURE [STRING];
These procedures invoke the Debugger without the overhead of raising an uncaught signal. The Debugger will display the parameter if it is not NIL. The worry call will invoke the Debugger in worry mode.
SystemDefs
Even: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED];
Rounds u up to a multiple of two. Can be used to align pointers on even word boundaries.
Quad: PROCEDURE [u: UNSPECIFIED] RETURNS [UNSPECIFIED];
Rounds u up to a multiple of four. Can be used to align pointers on quad word boundaries.
InlineDefs
The following procedures and types are defined in InlineDefs. Most are also available from the interface Inline.
COPY: PROCEDURE [from: POINTER, nwords: CARDINAL, to: POINTER];
FOR i IN [0..nwords) DO (to+i)↑ ← (from+i)↑.
LongCOPY: PROCEDURE [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER];
FOR i IN [0..nwords) DO (to+i)↑ ← (from+i)↑.
This may be used only if
memConfig.xmMicrocode is TRUE. See Segment Package (Extended Memory Operations) in this document for details.
DIVMOD: PROCEDURE [num, den: CARDINAL] RETURNS [quotient, remainder: CARDINAL];
Returns both the quotient and remainder of the unsigned division of num by den.
LDIVMOD: PROCEDURE [numlow: WORD, numhigh: CARDINAL, den: CARDINAL]
RETURNS [quotient, remainder: CARDINAL];
Like DIVMOD except that the numerator is the double length unsigned number numhigh*216 + numlow. Results are undefined if the quotient is greater than 216-1.
LongNumber: TYPE = MACHINE DEPENDENT RECORD [
SELECT OVERLAID * FROM
lc => [lc: LONG CARDINAL],
li => [li:
LONG INTEGER],
lu => [lu:
LONG UNSPECIFIED],
num => [lowbits, highbits:
CARDINAL],
ENDCASE];
The LongNumber structure permits access to the high and low words of LONG CARDINALs and LONG INTEGERs. Alternately, the following procedures may be used:
LowHalf: PROCEDURE [LONG UNSPECIFIED] RETURNS [UNSPECIFIED];
HighHalf: PROCEDURE [LONG UNSPECIFIED] RETURNS [UNSPECIFIED];
LowHalf and HighHalf allow access to the machine dependent components of LONG CARDINALs, LONG INTEGERs and LONG POINTERs. LowHalf returns the least significant word, while HighHalf returns the most significant word.
BytePair: TYPE = RECORD [high, low: [0..256)];
LowByte: PROCEDURE [UNSPECIFIED] RETURNS [UNSPECIFIED];
HighByte: PROCEDURE [UNSPECIFIED] RETURNS [UNSPECIFIED];
LowByte and HighByte return the least significant and most significant byte of a word respectively.
LongMult: PROCEDURE [CARDINAL, CARDINAL] RETURNS [product: LONG CARDINAL];
Returns the double precision result of the unsigned multiplication of the two single precision arguments.
LongDiv: PROCEDURE [num: LONG CARDINAL, den: CARDINAL] RETURNS [CARDINAL];
Returns the result of the unsigned division of num by den. The result is undefined if the quotient is greater than 216-1.
LongDivMod: PROCEDURE [num: LONG CARDINAL, den: CARDINAL]
RETURNS [quotient, remainder: CARDINAL];
Like LongDiv except both quotient and remainder are returned.
BITAND, BITOR, BITXOR: PROCEDURE [UNSPECIFIED, UNSPECIFIED] RETURNS [UNSPECIFIED];
These functions compute the bitwise AND, OR, or XOR of their arguments.
BITNOT: PROCEDURE [UNSPECIFIED] RETURNS [UNSPECIFIED];
Returns the ones complement of the input.
BITSHIFT: PROCEDURE [value: UNSPECIFIED, count: INTEGER] RETURNS [UNSPECIFIED];
Returns value shifted by ABS[count] bits. The shift is left if count > 0, right if count < 0.
Floating Point
It is possible to use floating point arithmetic on machines without microcode support for floating point. With the proper compile-time switch, the Compiler generates calls to client supplied procedures via the system data vector (SD). The definitions of SD and all indexes into SD are in SDDefs. In the following description the notation
SD[index]: PROCEDURE . . .
means that the client should declare a procedure P of the correct type and assign its descriptor to the appropriate element of SD (SD[index] ← P). In this case, the Compiler makes no assumptions about the representation of REALs except that they occupy two words.
SD[sFADD]: PROCEDURE [a, b: REAL] RETURNS [REAL];
Called to perform addition.
SD[sFSUB]: PROCEDURE [a, b: REAL] RETURNS [REAL];
Called to perform subtraction.
SD[sFMUL]: PROCEDURE [a, b: REAL] RETURNS [REAL];
Performs multiplication.
SD[sFDIV]: PROCEDURE [a, b: REAL] RETURNS [REAL];
Performs division (a/b).
SD[sFCOMP]: PROCEDURE [a, b: REAL] RETURNS [INTEGER];
Called to compare REALs. Returns -1 if a<b, 0 if a=b, 1 if a>b.
SD[sFLOAT]: PROCEDURE [LONG INTEGER] RETURNS [REAL];
Converts fixed point to floating point.
SD[sFIX]: PROCEDURE [REAL] RETURNS [LONG INTEGER];
The Compiler does not generate calls to this procedure. It is included for completeness.
BitBlt
The Alto has microcode for moving arbitrary rectangles of bits around in memory. The operation is called BitBlt. BitBlt operations are specified via a table of parameters. One should read the Alto Hardware Manual for a detailed description of the BitBlt operation. Mesa provides the following definitions, in BitBltDefs for using BitBlt:
BBTable: TYPE = MACHINE DEPENDENT RECORD [
ptrs: {short, long} ← short,
pad: [0..777B] ← 0,
sourcealt, destalt: BOOLEANFALSE, -- TRUE to use alternate memory bank
sourcetype: BBsourcetype ← block,
function: BBoperation ← replace,
unused: CARDINAL ← 0, -- used to set emulator bank register during operation
dbca: POINTERNULL, -- destination BaseCoreAddress
dbmr: CARDINALNULL, -- destination raster width(in words)
dlx: CARDINALNULL, -- destination left x
dty: CARDINALNULL, -- destination top y
dw: CARDINALNULL,
dh: CARDINALNULL,
sbca: POINTERNULL, -- source BaseCoreAddress
sbmr: CARDINALNULL, -- source raster width(in words)
slx: CARDINALNULL, -- source left x
sty: CARDINALNULL, -- source top y
gray0: CARDINALNULL, -- four words of "gray"
gray1: CARDINALNULL,
gray2: CARDINALNULL,
gray3: CARDINALNULL, -- Below here is not used by nonXM, nonXMesa Altos
slbca: LONG POINTERNULL, -- source long BaseCoreAddress
dlbca: LONG POINTERNULL]; -- destination long BaseCoreAddress
BBptr: TYPE = POINTER TO BBTable;
BBoperation: TYPE = {replace, paint, invert, erase};
BBsourcetype: TYPE = {block, complement, andgray, gray};
The hardware/microcode requires that BBTable be at an even memory address. Mesa therefore provides a type and transfer procedure so that one can allocate one word too many and be assured of an even address.
BBTableSpace: TYPE = ARRAY [0..SIZE[BBTable]] OF UNSPECIFIED;
AlignedBBTable: PROCEDURE [p: POINTER TO BBTableSpace] RETURNS [BBptr];
Finally, there is the operation itself:
BITBLT: PROCEDURE [ptr: BBptr];
These declarations are used in the following way:
bbBits: BBTableSpace;
bbP: BBptr = AlignedBBTable[@bbBits];
. . .
bbP↑ ← [ desired values for a given operation ];
BITBLT[bbP];
. . .
Mesa provides support for the BitBlt operation in conjunction with extended memory.The sourcealt and destalt fields of the BitBlt record (BitBltDefs.BBTable) are used (do not use the long pointer options). If the unused word in the BBTable is nonzero, the microcode sets the emulator bank register to that value for the duration of the BitBlt. In effect, BitBlt can only be used to move data within a single bank or between the MDS (bank zero) and some other bank.