MakeScannerProms.mesa
HGM, December 13, 1984 0:10:39 am PST
Last Edited by: Diebert, March 11, 1985 9:29:49 am PST
Compile DTProms
Run DTProms
Copy /Ivy/Murray/DT/DTProms.mesa ← DTProms.mesa
Copy /Ivy/Murray/DT/DTProms.mb ← DTProms.mb
DIRECTORY
Convert USING [RopeFromTime],
FS USING [StreamOpen],
IO USING [Close, PutChar, PutRope, STREAM],
Loader USING [BCDBuildTime],
Rope USING [Cat, Length, ROPE];
MakeScannerProms: CEDAR PROGRAM
IMPORTS Convert, FS, IO, Loader, Rope =
BEGIN
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
mb: STREAMNIL;
memory: CARDINAL ← 0;
Bit: TYPE = BOOLEAN;
clearOut: CARDINAL ~ 65135;
minITime: CARDINAL ~ 63336;
maxITime: CARDINAL ~ 40000;
IntegrationTime: PROC =
BEGIN
addr: RECORD [
blank: [0..37B], -- 5 bits of waste.
region: [0 .. 7B], -- 3 bits of selects
clearOut: Bit, -- force clear out time
iTime: [0 .. 77B], -- 6 bits of iTime
highByte: Bit ]; -- low/high
output: CARDINAL;
inc: CARDINAL ← (minITime - maxITime)/ 64;
StartNewMemory["ITime", 8];
FOR i: CARDINAL IN [0 .. 2048) DO
TRUSTED { addr ← LOOPHOLE[i]; };
IF NOT addr.highByte THEN LOOP;
output ← clearOut;
SELECT addr.region FROM
0 => BEGIN
IF NOT addr.clearOut THEN output ← minITime - (inc * addr.iTime);
END;
ENDCASE => NULL;
PutWord[1]; -- Memory contents
PutWord[0]; -- Source line number
PutLowByte[output];
PutWord[1]; -- Memory contents
PutWord[0]; -- Source line number
PutHighByte[output];
ENDLOOP;
END;
PutTimeStamp: PROC [name: ROPE] =
BEGIN
PutWord[4]; -- Define (fake) Memory
memory ← memory + 1;
PutWord[memory];
PutWord[8];
name ← Rope.Cat[name, " of ", Convert.RopeFromTime[Loader.BCDBuildTime[DoIt]]];
PutRope[name];
END;
StartNewMemory: PROC [name: ROPE, bitsPerWord: CARDINAL] =
BEGIN
PutWord[4]; -- Define Memory
memory ← memory + 1;
PutWord[memory];
PutWord[bitsPerWord];
PutRope[name];
PutWord[2]; -- Set Current Memory
PutWord[memory];
PutWord[0]; -- Current PC
END;
PutRope: PROC [rope: ROPE] =
BEGIN
IO.PutRope[mb, rope];
PutByte[0]; -- End of string
IF (rope.Length[] MOD 2) = 0 THEN PutByte[0]; -- Round up to word
END;
PutWord: PROC [data: CARDINAL] = TRUSTED
BEGIN
IO.PutChar[mb, LOOPHOLE[data/256, CHAR]];
IO.PutChar[mb, LOOPHOLE[data, CHAR]];
END;
PutBytePair: PROC [data: CARDINAL] = BEGIN
PutLowByte[data];
PutHighByte[data];
END;
PutHighByte: PROC [data: CARDINAL] = TRUSTED BEGIN
md: MACHINE DEPENDENT RECORD [a, b: [0 .. 256)] ← LOOPHOLE [data];
md.b ← 0;
PutWord[LOOPHOLE[md]];
END;
PutLowByte: PROC [data: CARDINAL] = TRUSTED BEGIN
md: MACHINE DEPENDENT RECORD [a, b: [0 .. 256)] ← LOOPHOLE [data];
md.a ← md.b; md.b ← 0;
PutWord[LOOPHOLE[md]];
END;
PutByte: PROC [data: CARDINAL] = TRUSTED
BEGIN
IO.PutChar[mb, LOOPHOLE[data, CHAR]];
END;
DoIt: PROCEDURE =
BEGIN
mb ← FS.StreamOpen["ScannerProms.mb", $create];
PutTimeStamp["ScannerProms.mb"];
IntegrationTime[];
PutWord[0]; -- End of data marker
IO.Close[mb];
mb ← NIL;
END;
DoIt[];
END.