8SA1Sim/js/isa/alu.js

352 lines
12 KiB
JavaScript

// This is a simple ADD command which will ADD GPA and GPB putting the sum in GPA
class IS_ADD extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x300;
this.Mnemonic = "ADD";
this.LongName = "Addition";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_ADD | CONTROL_OUT_AB;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO;
}
}
is_ADD = new IS_ADD;
Instructions.push(is_ADD);
class IS_SUB extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x301;
this.Mnemonic = "SUB";
this.LongName = "Subtraction";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_SUB;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO;
}
}
is_SUB = new IS_SUB;
Instructions.push(is_SUB);
class IS_NOT extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x302;
this.Mnemonic = "NOT";
this.LongName = "Logical NOT";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 9;
this.Microcode[2] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_AL | CONTROL_RI | CONTROL_SPD | CONTROL_SPC;
this.Microcode[4] = CONTROL_RAIL;
this.Microcode[5] = CONTROL_ALU_NOT;
this.Microcode[6] = CONTROL_OUT_AO | CONTROL_RBIL | CONTROL_SPC;
this.Microcode[7] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[8] = CONTROL_OUT_RO | CONTROL_RAIL;
}
}
is_NOT = new IS_NOT;
Instructions.push(is_NOT);
class IS_FNOT extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x303;
this.Mnemonic = "FNOT";
this.LongName = "Logical FAST NOT";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_NOT;
this.Microcode[3] = CONTROL_RBIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_FNOT = new IS_FNOT;
Instructions.push(is_FNOT);
class IS_AND extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x304;
this.Mnemonic = "AND";
this.LongName = "Logical AND";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_AND;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_AND = new IS_AND;
Instructions.push(is_AND);
class IS_NAND extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x305;
this.Mnemonic = "NAND";
this.LongName = "Logical NAND";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_NAND;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_NAND = new IS_NAND;
Instructions.push(is_NAND);
class IS_OR extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x306;
this.Mnemonic = "OR";
this.LongName = "Logical OR";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_OR;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_OR = new IS_OR;
Instructions.push(is_OR);
class IS_NOR extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x307;
this.Mnemonic = "NOR";
this.LongName = "Logical NOR";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_NOR;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_NOR = new IS_NOR;
Instructions.push(is_NOR);
class IS_XOR extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x308;
this.Mnemonic = "XOR";
this.LongName = "Logical XOR";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_XOR;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_XOR = new IS_XOR;
Instructions.push(is_XOR);
class IS_XNOR extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x309;
this.Mnemonic = "XNOR";
this.LongName = "Logical XNOR";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_ALU_XNOR;
this.Microcode[3] = CONTROL_RAIL | CONTROL_OUT_AO | CONTROL_SPC;
}
}
is_XNOR = new IS_XNOR;
Instructions.push(is_XNOR);
class IS_CMP extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30A;
this.Mnemonic = "CMP";
this.LongName = "Logical COMPARE";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "B", Bitwidth: 8});
this.Words = 1;
this.Cycles = 3;
this.Microcode[2] = CONTROL_OUT_AB | CONTROL_ALU_ADD;
}
}
is_CMP = new IS_CMP;
Instructions.push(is_CMP);
class IS_CMP_gpcd_abs extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30B;
this.Mnemonic = "CMP";
this.LongName = "Logical COMPARE";
this.Aliases = new Array();
this.Type = InstructionTypes.RegisterAbsolute;
this.Operands = new Array({Operand: "CD", Bitwidth: 16});
this.Words = 1;
this.Cycles = 4;
this.Microcode[2] = CONTROL_OUT_CD | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_RO | CONTROL_ALU_ADD;
}
}
is_CMP_cda = new IS_CMP_gpcd_abs();
Instructions.push(is_CMP_cda);
class IS_CMP_gpc_gpd extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30C;
this.Mnemonic = "CMP";
this.LongName = "Logical COMPARE";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "C", Bitwidth: 8},{Operand: "D", Bitwidth: 8});
this.Words = 1;
this.Cycles = 3;
this.Microcode[2] = CONTROL_OUT_CD | CONTROL_ALU_ADD;
}
}
is_CMP_c_d = new IS_CMP_gpc_gpd();
Instructions.push(is_CMP_c_d);
class IS_ADD_gpa_imm extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30D;
this.Mnemonic = "ADD";
this.LongName = "Addition";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "A", Bitwidth: 8},{Operand: "$", Bitwidth: 8});
this.Words = 2;
this.Cycles = 10;
this.Microcode[2] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_BL | CONTROL_RI | CONTROL_SPD | CONTROL_SPC;
this.Microcode[4] = CONTROL_OUT_PC | CONTROL_RRI;
this.Microcode[5] = CONTROL_OUT_RO | CONTROL_RBIL | CONTROL_PCC;
this.Microcode[6] = CONTROL_OUT_AB | CONTROL_ALU_ADD;
this.Microcode[7] = CONTROL_OUT_AO | CONTROL_RAIL | CONTROL_SPC;
this.Microcode[8] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[9] = CONTROL_OUT_RO | CONTROL_RBIL;
}
}
is_ADD_gpai = new IS_ADD_gpa_imm;
Instructions.push(is_ADD_gpai);
class IS_ADD_gpb_imm extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30E;
this.Mnemonic = "ADD";
this.LongName = "Addition";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "B", Bitwidth: 8},{Operand: "$", Bitwidth: 8});
this.Words = 2;
this.Cycles = 10;
this.Microcode[2] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_AL | CONTROL_RI | CONTROL_SPD | CONTROL_SPC;
this.Microcode[4] = CONTROL_OUT_PC | CONTROL_RRI;
this.Microcode[5] = CONTROL_OUT_RO | CONTROL_RAIL | CONTROL_PCC;
this.Microcode[6] = CONTROL_OUT_AB | CONTROL_ALU_ADD;
this.Microcode[7] = CONTROL_OUT_AO | CONTROL_RBIL | CONTROL_SPC;
this.Microcode[8] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[9] = CONTROL_OUT_RO | CONTROL_RAIL;
}
}
is_ADD_gpbi = new IS_ADD_gpb_imm;
Instructions.push(is_ADD_gpbi);
class IS_ADD_gpc_imm extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x30F;
this.Mnemonic = "ADD";
this.LongName = "Addition";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "C", Bitwidth: 8},{Operand: "$", Bitwidth: 8});
this.Words = 2;
this.Cycles = 10;
this.Microcode[2] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_AL | CONTROL_RI | CONTROL_SPD | CONTROL_SPC;
this.Microcode[4] = CONTROL_OUT_PC | CONTROL_RRI;
this.Microcode[5] = CONTROL_OUT_RO | CONTROL_RAIL | CONTROL_PCC;
this.Microcode[6] = CONTROL_OUT_CA | CONTROL_ALU_ADD;
this.Microcode[7] = CONTROL_OUT_AO | CONTROL_RCIL | CONTROL_SPC;
this.Microcode[8] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[9] = CONTROL_OUT_RO | CONTROL_RAIL;
}
}
is_ADD_gpci = new IS_ADD_gpc_imm;
Instructions.push(is_ADD_gpci);
class IS_ADD_gpd_imm extends Microcode_Instruction {
constructor(props) {
super(props);
this.Bytecode = 0x310;
this.Mnemonic = "ADD";
this.LongName = "Addition";
this.Aliases = new Array();
this.Type = InstructionTypes.Register;
this.Operands = new Array({Operand: "D", Bitwidth: 8},{Operand: "$", Bitwidth: 8});
this.Words = 2;
this.Cycles = 10;
this.Microcode[2] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[3] = CONTROL_OUT_AL | CONTROL_RI | CONTROL_SPD | CONTROL_SPC;
this.Microcode[4] = CONTROL_OUT_PC | CONTROL_RRI;
this.Microcode[5] = CONTROL_OUT_RO | CONTROL_RAIL | CONTROL_PCC;
this.Microcode[6] = CONTROL_OUT_DA | CONTROL_ALU_ADD;
this.Microcode[7] = CONTROL_OUT_AO | CONTROL_RDIL | CONTROL_SPC;
this.Microcode[8] = CONTROL_OUT_SP | CONTROL_RRI;
this.Microcode[9] = CONTROL_OUT_RO | CONTROL_RAIL;
}
}
is_ADD_gpdi = new IS_ADD_gpd_imm;
Instructions.push(is_ADD_gpdi);