LizardInstructionOutputImpl.mesa
Russ Atkinson, March 21, 1984 7:26:38 pm PST
DIRECTORY
DragOpsCross,
DragOpsCrossUtils,
LizardInstructionOutput,
IO,
Rope;
LizardInstructionOutputImpl: CEDAR PROGRAM
IMPORTS DragOpsCrossUtils, IO
EXPORTS LizardInstructionOutput
= BEGIN OPEN LizardInstructionOutput;
ZerosByte: DragOpsCross.Byte = DragOpsCross.ZerosByte;
ZerosWord: Word = DragOpsCross.ZerosWord;
ToStream: PUBLIC PROC [stream: STREAM, inst: Inst, rest: Word, pc: Word] = {
code: CARDINAL = LOOPHOLE[inst];
len: CARDINAL ← code / 64;
IF len = 0 THEN IF code < 40B THEN len ← 1 ELSE len ← 5;
IO.PutRope[stream, nameArray[inst]];
SELECT len FROM
1 => RETURN;
2 => {
alphaZ: CARDINAL =
DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][3]];
SELECT inst FROM
IN DragOpsCross.LRBformatRange => {
IO.PutF[stream, " r%g, ", [cardinal[code/16]]];
IO.PutF[stream, " %bB (%g)", [cardinal[alphaZ]], [cardinal[alphaZ]]];
};
dJB => {
dest: INT ← alphaZ;
IF alphaZ > 127 THEN dest ← dest - 256;
dest ← DragOpsCrossUtils.WordToInt[pc] + dest;
IO.PutF[stream, " %bB (pc: %bB)", [cardinal[alphaZ]], [cardinal[dest]]];
};
ENDCASE =>
IO.PutF[stream, " %bB (%g)", [cardinal[alphaZ]], [cardinal[alphaZ]]];
};
3 => {
alphaZ: CARDINAL =
DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][3]];
betaZ: CARDINAL =
DragOpsCrossUtils.ByteToCard[DragOpsCrossUtils.WordToBytes[rest][2]];
alphaBetaZ: CARDINAL = alphaZ + betaZ*256;
dest: INT ← alphaZ;
PutArg: PROC [prefix: ROPE, aux,opt: BOOL, reg: [0..15], dst: BOOLFALSE] = {
IO.PutRope[stream, prefix];
IF NOT opt
THEN IO.PutF[stream, IF aux THEN "a%g" ELSE "r%g", [cardinal[reg]]]
ELSE SELECT reg FROM
12 => IO.PutRope[stream, "[S]"];
13 => IO.PutRope[stream, "[S-1]"];
14 => IO.PutRope[stream, IF dst THEN "[S+1]+" ELSE "[S]-"];
15 => IO.PutRope[stream, IF dst THEN "[S+1]+" ELSE "[S-1]-"];
ENDCASE => IO.PutF[stream, "c%g", [cardinal[reg]]];
};
IF alphaZ > 127 THEN dest ← dest - 256;
dest ← DragOpsCrossUtils.WordToInt[pc] + dest;
SELECT inst FROM
IN DragOpsCross.RRformatRange => {
rb: DragOpsCross.FourBytes ← DragOpsCrossUtils.WordToBytes[rest];
form: DragOpsCross.RRformat = LOOPHOLE[DragOpsCross.FourBytes[
ZerosByte, rb[3], rb[2], ZerosByte]];
PutArg[" ", form.aux, form.cOpt, form.c];
PutArg[", ", form.aux, form.aOpt, form.a];
PutArg[", ", form.aux, form.bOpt, form.b];
};
IN DragOpsCross.RJBformatRange => {
destPC: LONG CARDINALLOOPHOLE[dest];
rb: DragOpsCross.FourBytes ← DragOpsCrossUtils.WordToBytes[rest];
form: DragOpsCross.RJBformat = LOOPHOLE[DragOpsCross.FourBytes[
ZerosByte, rb[3], rb[2], ZerosByte]];
PutArg[" ", form.aux, form.opt, form.reg];
IO.PutF[stream, ", %bB (pc: %bB)", [cardinal[alphaBetaZ]], [cardinal[destPC]]];
};
IN DragOpsCross.LRRBformatRange => {
IO.PutF[stream, " r%g, [r%g]%bB (%g)",
[cardinal[betaZ/16]], [cardinal[betaZ MOD 16]],
[cardinal[alphaZ]], [cardinal[alphaZ]]];
};
IN DragOpsCross.JBBformatRange => {
destPC: LONG CARDINAL = LOOPHOLE[dest];
IO.PutF[stream, " %bB (%g), %bB (pc: %bB)",
[cardinal[betaZ]], [cardinal[betaZ]], [cardinal[destPC]], [cardinal[destPC]]];
};
dJDB, dLFC => {
destPC: LONG CARDINAL = LOOPHOLE[dest];
dest ← LOOPHOLE[alphaBetaZ, INTEGER] + DragOpsCrossUtils.WordToInt[pc];
IO.PutF[stream, " %bB (pc: %bB)", [cardinal[alphaBetaZ]], [cardinal[destPC]]];
};
dSHL, dSHR => {
fd: DragOpsCross.FieldDescriptor = LOOPHOLE[alphaBetaZ];
dest ← LOOPHOLE[alphaBetaZ, INTEGER] + DragOpsCrossUtils.WordToInt[pc];
IO.PutF[stream, " %bB (", [cardinal[alphaBetaZ]]];
IF fd.reserved # 0 THEN IO.PutF[stream, "reserved: %g, ", [cardinal[fd.reserved]]];
IF fd.insert THEN IO.PutRope[stream, "insert: TRUE, "];
IO.PutF[stream, "mask: %g, shift: %g)", [cardinal[fd.mask]], [cardinal[fd.shift]]];
};
ENDCASE =>
IO.PutF[stream, " %bB (%g)", [cardinal[alphaBetaZ]], [cardinal[alphaBetaZ]]];
};
5 => {
card: LONG CARDINAL = DragOpsCrossUtils.WordToCard[rest];
int: INT = DragOpsCrossUtils.WordToInt[rest];
IO.PutF[stream, " %bB (%g)", [cardinal[card]], [integer[int]]];
};
ENDCASE => ERROR;
};
GetInstArray: PUBLIC PROC RETURNS [array: NameArray] = {
RETURN [nameArray];
};
GetRegArray: PUBLIC PROC RETURNS [array: RegNameArray] = {
RETURN [regNameArray];
};
InitArray: PROC RETURNS [array: NameArray] = {
array ← NEW[NameArrayRep];
FOR inst: Inst IN Inst DO
instName: ROPE ←
SELECT inst FROM
dDFC => "DFC", dJ5 => "J5", dLC0 => "LC0", dLC1 => "LC1", dLC2 => "LC2", dLC3 => "LC3", dLC4 => "LC4", dLC5 => "LC5", dLC6 => "LC6", dLC7 => "LC7", dADD => "ADD", dBNDCK => "BNDCK", dDIS => "DIS", dDUP => "DUP", dEXCH => "EXCH", dEXDIS => "EXDIS", dJ1 => "J1", dRETN => "RETN", dRETT => "RETT", dSFC => "SFC", dSFCI => "SFCI", dSJ => "SJ", dSUB => "SUB", dLR0 => "LR0", dLR1 => "LR1", dLR2 => "LR2", dLR3 => "LR3", dLR4 => "LR4", dLR5 => "LR5", dLR6 => "LR6", dLR7 => "LR7", dLR8 => "LR8", dLR9 => "LR9", dLR10 => "LR10", dLR11 => "LR11", dLR12 => "LR12", dLR13 => "LR13", dLR14 => "LR14", dLR15 => "LR15", dSR0 => "SR0", dSR1 => "SR1", dSR2 => "SR2", dSR3 => "SR3", dSR4 => "SR4", dSR5 => "SR5", dSR6 => "SR6", dSR7 => "SR7", dSR8 => "SR8", dSR9 => "SR9", dSR10 => "SR10", dSR11 => "SR11", dSR12 => "SR12", dSR13 => "SR13", dSR14 => "SR14", dSR15 => "SR15", dADDB => "ADDB", dARL => "ARL", dAS => "AS", dCST => "CST", dEP => "EP", dIN => "IN", dJ2 => "J2", dJB => "JB", dLEUR => "LEUR", dLIB => "LIB", dLIFUR => "LIFUR", dOUT => "OUT", dPSB => "PSB", dRB => "RB", dRET => "RET", dRSB => "RSB", dSEUR => "SEUR", dSIFUR => "SIFUR", dSUBB => "SUBB", dWB => "WB", dWSB => "WSB", dLRI0 => "LRI0", dLRI1 => "LRI1", dLRI2 => "LRI2", dLRI3 => "LRI3", dLRI4 => "LRI4", dLRI5 => "LRI5", dLRI6 => "LRI6", dLRI7 => "LRI7", dLRI8 => "LRI8", dLRI9 => "LRI9", dLRI10 => "LRI10", dLRI11 => "LRI11", dLRI12 => "LRI12", dLRI13 => "LRI13", dLRI14 => "LRI14", dLRI15 => "LRI15", dSRI0 => "SRI0", dSRI1 => "SRI1", dSRI2 => "SRI2", dSRI3 => "SRI3", dSRI4 => "SRI4", dSRI5 => "SRI5", dSRI6 => "SRI6", dSRI7 => "SRI7", dSRI8 => "SRI8", dSRI9 => "SRI9", dSRI10 => "SRI10", dSRI11 => "SRI11", dSRI12 => "SRI12", dSRI13 => "SRI13", dSRI14 => "SRI14", dSRI15 => "SRI15", dRADD => "RADD", dRAND => "RAND", dRFU => "RFU", dRLADD => "RLADD", dRLSUB => "RLSUB", dROR => "ROR", dRRX => "RRX", dRSUB => "RSUB", dRUADD => "RUADD", dRUSUB => "RUSUB", dRVADD => "RVADD", dRVSUB => "RVSUB", dRXOR => "RXOR", dRJEB => "RJEB", dRJEBJ => "RJEBJ", dRJGB => "RJGB", dRJGBJ => "RJGBJ", dRJGEB => "RJGEB", dRJGEBJ => "RJGEBJ", dRJLB => "RJLB", dRJLBJ => "RJLBJ", dRJLEB => "RJLEB", dRJLEBJ => "RJLEBJ", dRJNEB => "RJNEB", dRJNEBJ => "RJNEBJ", dADDDB => "ADDDB", dFSDB => "FSDB", dJ3 => "J3", dJDB => "JDB", dLFC => "LFC", dLGF => "LGF", dLIDB => "LIDB", dSHL => "SHL", dSHR => "SHR", dRAI => "RAI", dRRI => "RRI", dWAI => "WAI", dWRI => "WRI", dJEBB => "JEBB", dJEBBJ => "JEBBJ", dJNEBB => "JNEBB", dJNEBBJ => "JNEBBJ",
ENDCASE => NIL;
IF instName = NIL THEN {
instName ← IO.PutFR["X%b", [cardinal[LOOPHOLE[inst, CARDINAL]]]];
};
array[inst] ← instName;
ENDLOOP;
};
InitRegArray: PROC RETURNS [array: RegNameArray] = {
array ← NEW[RegNameArrayRep];
FOR reg: ProcessorRegister IN ProcessorRegister DO
name: ROPENIL;
regc: CARDINAL = LOOPHOLE[reg];
SELECT reg FROM
IN [euStack..euMDF) =>
name ← IO.PutFR["s%g", [cardinal[regc]]];
IN [euAux..euSpare0) => {
base: ProcessorRegister = euAux;
name ← IO.PutFR["a%g", [cardinal[regc - LOOPHOLE[base, CARDINAL]]]]};
IN [euConstant..euBogus) => {
base: ProcessorRegister = euAux;
name ← IO.PutFR["c%g", [cardinal[regc - LOOPHOLE[base, CARDINAL]]]]};
euMDF => name ← "euMDF";
euMQ => name ← "euMQ";
euMAR => name ← "euMAR";
euJunk => name ← "euJunk";
euUseK => name ← "euUseK";
euUseK => name ← "euUseK";
ifuStatus => name ← "ifuStatus";
ifuEldestL => name ← "ifuEldestL";
ifuEldestPC => name ← "ifuEldestPC";
ifuYoungestL => name ← "ifuYoungestL";
ifuYoungestPC => name ← "ifuYoungestPC";
ifuSLimit => name ← "ifuSLimit";
ifuL => name ← "ifuL";
ifuS => name ← "ifuS";
ifuPC => name ← "ifuPC";
IN DragOpsCross.EURegs => name ← IO.PutFR["eu#%g", [cardinal[regc]]];
IN DragOpsCross.IFURegs => name ← IO.PutFR["ifu#%g", [cardinal[regc]]];
ENDCASE => ERROR;
array[reg] ← name;
ENDLOOP;
};
nameArray: NameArray = InitArray[];
regNameArray: RegNameArray = InitRegArray[];
END.