Format code and fix warnings.

This commit is contained in:
Deryck Brown
2022-05-12 18:44:37 +01:00
parent 2c426b5b2e
commit a02acc009b
114 changed files with 5700 additions and 5953 deletions
@@ -21,44 +21,44 @@ import java.io.IOException;
public class Instruction {
public Instruction() {
op = 0;
r = 0;
n = 0;
d = 0;
}
public Instruction() {
op = 0;
r = 0;
n = 0;
d = 0;
}
// Java has no type synonyms, so the following representations are
// assumed:
//
// type
// OpCode = 0..15; {4 bits unsigned}
// Length = 0..255; {8 bits unsigned}
// Operand = -32767..+32767; {16 bits signed}
// Java has no type synonyms, so the following representations are
// assumed:
//
// type
// OpCode = 0..15; {4 bits unsigned}
// Length = 0..255; {8 bits unsigned}
// Operand = -32767..+32767; {16 bits signed}
// Represents TAM instructions.
public int op; // OpCode
public int r; // RegisterNumber
public int n; // Length
public int d; // Operand
// Represents TAM instructions.
public int op; // OpCode
public int r; // RegisterNumber
public int n; // Length
public int d; // Operand
public void write(DataOutputStream output) throws IOException {
output.writeInt(op);
output.writeInt(r);
output.writeInt(n);
output.writeInt(d);
}
public void write(DataOutputStream output) throws IOException {
output.writeInt(op);
output.writeInt(r);
output.writeInt(n);
output.writeInt(d);
}
public static Instruction read(DataInputStream input) throws IOException {
Instruction inst = new Instruction();
try {
inst.op = input.readInt();
inst.r = input.readInt();
inst.n = input.readInt();
inst.d = input.readInt();
return inst;
} catch (EOFException s) {
return null;
}
}
public static Instruction read(DataInputStream input) throws IOException {
Instruction inst = new Instruction();
try {
inst.op = input.readInt();
inst.r = input.readInt();
inst.n = input.readInt();
inst.d = input.readInt();
return inst;
} catch (EOFException s) {
return null;
}
}
}
@@ -16,110 +16,56 @@ package Triangle.AbstractMachine;
public final class Machine {
public final static int maxRoutineLevel = 7;
public final static int maxRoutineLevel = 7;
// WORDS AND ADDRESSES
// WORDS AND ADDRESSES
// Java has no type synonyms, so the following representations are
// assumed:
//
// type
// Word = -32767..+32767; {16 bits signed}
// DoubleWord = -2147483648..+2147483647; {32 bits signed}
// CodeAddress = 0..+32767; {15 bits unsigned}
// DataAddress = 0..+32767; {15 bits unsigned}
// Java has no type synonyms, so the following representations are
// assumed:
//
// type
// Word = -32767..+32767; {16 bits signed}
// DoubleWord = -2147483648..+2147483647; {32 bits signed}
// CodeAddress = 0..+32767; {15 bits unsigned}
// DataAddress = 0..+32767; {15 bits unsigned}
// INSTRUCTIONS
// INSTRUCTIONS
// Operation codes
public final static int LOADop = 0,
LOADAop = 1,
LOADIop = 2,
LOADLop = 3,
STOREop = 4,
STOREIop = 5,
CALLop = 6,
CALLIop = 7,
RETURNop = 8,
PUSHop = 10,
POPop = 11,
JUMPop = 12,
JUMPIop = 13,
JUMPIFop = 14,
HALTop = 15;
// Operation codes
public final static int LOADop = 0, LOADAop = 1, LOADIop = 2, LOADLop = 3, STOREop = 4, STOREIop = 5, CALLop = 6,
CALLIop = 7, RETURNop = 8, PUSHop = 10, POPop = 11, JUMPop = 12, JUMPIop = 13, JUMPIFop = 14, HALTop = 15;
// CODE STORE
// CODE STORE
public static Instruction[] code = new Instruction[1024];
public static Instruction[] code = new Instruction[1024];
// CODE STORE REGISTERS
// CODE STORE REGISTERS
public final static int CB = 0,
PB = 1024, // = upper bound of code array + 1
PT = 1052; // = PB + 28
public final static int CB = 0, PB = 1024, // = upper bound of code array + 1
PT = 1052; // = PB + 28
// REGISTER NUMBERS
// REGISTER NUMBERS
public final static int CBr = 0,
CTr = 1,
PBr = 2,
PTr = 3,
SBr = 4,
STr = 5,
HBr = 6,
HTr = 7,
LBr = 8,
L1r = LBr + 1,
L2r = LBr + 2,
L3r = LBr + 3,
L4r = LBr + 4,
L5r = LBr + 5,
L6r = LBr + 6,
CPr = 15;
public final static int CBr = 0, CTr = 1, PBr = 2, PTr = 3, SBr = 4, STr = 5, HBr = 6, HTr = 7, LBr = 8,
L1r = LBr + 1, L2r = LBr + 2, L3r = LBr + 3, L4r = LBr + 4, L5r = LBr + 5, L6r = LBr + 6, CPr = 15;
// DATA REPRESENTATION
// DATA REPRESENTATION
public final static int booleanSize = 1,
characterSize = 1,
integerSize = 1,
addressSize = 1,
closureSize = 2 * addressSize,
public final static int booleanSize = 1, characterSize = 1, integerSize = 1, addressSize = 1,
closureSize = 2 * addressSize,
linkDataSize = 3 * addressSize,
linkDataSize = 3 * addressSize,
falseRep = 0,
trueRep = 1,
maxintRep = 32767;
falseRep = 0, trueRep = 1, maxintRep = 32767;
// ADDRESSES OF PRIMITIVE ROUTINES
// ADDRESSES OF PRIMITIVE ROUTINES
public final static int idDisplacement = 1,
notDisplacement = 2,
andDisplacement = 3,
orDisplacement = 4,
succDisplacement = 5,
predDisplacement = 6,
negDisplacement = 7,
addDisplacement = 8,
subDisplacement = 9,
multDisplacement = 10,
divDisplacement = 11,
modDisplacement = 12,
ltDisplacement = 13,
leDisplacement = 14,
geDisplacement = 15,
gtDisplacement = 16,
eqDisplacement = 17,
neDisplacement = 18,
eolDisplacement = 19,
eofDisplacement = 20,
getDisplacement = 21,
putDisplacement = 22,
geteolDisplacement = 23,
puteolDisplacement = 24,
getintDisplacement = 25,
putintDisplacement = 26,
newDisplacement = 27,
disposeDisplacement = 28;
public final static int idDisplacement = 1, notDisplacement = 2, andDisplacement = 3, orDisplacement = 4,
succDisplacement = 5, predDisplacement = 6, negDisplacement = 7, addDisplacement = 8, subDisplacement = 9,
multDisplacement = 10, divDisplacement = 11, modDisplacement = 12, ltDisplacement = 13, leDisplacement = 14,
geDisplacement = 15, gtDisplacement = 16, eqDisplacement = 17, neDisplacement = 18, eolDisplacement = 19,
eofDisplacement = 20, getDisplacement = 21, putDisplacement = 22, geteolDisplacement = 23,
puteolDisplacement = 24, getintDisplacement = 25, putintDisplacement = 26, newDisplacement = 27,
disposeDisplacement = 28;
}