Change structure of execute module w/ S
This commit is contained in:
parent
9a6d15ce1c
commit
64a9d72806
@ -19,7 +19,42 @@
|
||||
// Prototypes
|
||||
void execute_SDT(Machine *state, a64inst_instruction *inst);
|
||||
void execute_Branch(Machine *state, a64inst_instruction *inst);
|
||||
void executeMultiply(Machine *state, a64inst_instruction *inst);
|
||||
static void executeDPImmediate(Machine *state, a64inst_instruction *inst);
|
||||
static void executeDPRegister(Machine *state, a64inst_instruction *inst);
|
||||
|
||||
void execute(Machine *state, a64inst_instruction *inst) {
|
||||
|
||||
switch (inst->type) {
|
||||
|
||||
// Halt the program
|
||||
case a64inst_HALT:
|
||||
break;
|
||||
|
||||
// Execute a data processing immediate instruction
|
||||
case a64inst_DPIMMEDIATE:
|
||||
executeDPImmediate(state, inst);
|
||||
break;
|
||||
|
||||
// Execute a branch instruction
|
||||
case a64inst_BRANCH:
|
||||
execute_Branch(state, inst);
|
||||
break;
|
||||
|
||||
// Execute a data processing register instruction
|
||||
case a64inst_DPREGISTER:
|
||||
executeDPRegister(state, inst);
|
||||
break;
|
||||
|
||||
case a64inst_SINGLETRANSFER:
|
||||
execute_SDT(state, inst);
|
||||
break;
|
||||
|
||||
// Unknown instruction
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Updates N and Z condition codes given the machine and a result value
|
||||
static void updateCondNZ(Machine *state, dword result, a64inst_regType regType) {
|
||||
@ -241,7 +276,10 @@ static void executeDPRegister(Machine *state, a64inst_instruction *inst) {
|
||||
break;
|
||||
|
||||
// Execute a multiply register data processing instruction
|
||||
case a64inst_DPR_MULTIPLY:
|
||||
case a64inst_DPR_MULTIPLY:;
|
||||
dword product = state->registers[inst->data.DPRegisterData.src1] * state->registers[inst->data.DPRegisterData.src2];
|
||||
dword sum = readRegister(state, inst->data.DPRegisterData.processOpData.multiplydata.summand, inst->data.DPRegisterData.regType) + (inst->data.DPRegisterData.processOpData.multiplydata.negProd ? -product : product);
|
||||
writeRegister(state, inst->data.DPRegisterData.dest, inst->data.DPRegisterData.regType, sum);
|
||||
break;
|
||||
|
||||
// Unknown instruction detected!
|
||||
@ -251,43 +289,6 @@ static void executeDPRegister(Machine *state, a64inst_instruction *inst) {
|
||||
}
|
||||
}
|
||||
|
||||
void execute(Machine *state, a64inst_instruction *inst) {
|
||||
|
||||
switch (inst->type) {
|
||||
|
||||
// Halt the program
|
||||
case a64inst_HALT:
|
||||
break;
|
||||
|
||||
// Execute a data processing immediate instruction
|
||||
case a64inst_DPIMMEDIATE:
|
||||
executeDPImmediate(state, inst);
|
||||
break;
|
||||
|
||||
// Execute a branch instruction
|
||||
case a64inst_BRANCH:
|
||||
execute_Branch(state, inst);
|
||||
break;
|
||||
|
||||
// Execute a data processing register instruction
|
||||
case a64inst_DPREGISTER:
|
||||
if (inst->data.DPRegisterData.DPROpType == a64inst_DPR_MULTIPLY)
|
||||
executeMultiply(state, inst);
|
||||
else
|
||||
executeDPRegister(state, inst);
|
||||
break;
|
||||
|
||||
case a64inst_SINGLETRANSFER:
|
||||
execute_SDT(state, inst);
|
||||
break;
|
||||
|
||||
// Unknown instruction
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void execute_SDT(Machine *state, a64inst_instruction *inst) {
|
||||
word address;
|
||||
bool isLoad;
|
||||
@ -377,9 +378,3 @@ void execute_Branch(Machine *state, a64inst_instruction *inst) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void executeMultiply(Machine *state, a64inst_instruction *inst) {
|
||||
dword product = state->registers[inst->data.DPRegisterData.src1] * state->registers[inst->data.DPRegisterData.src2];
|
||||
dword sum = readRegister(state, inst->data.DPRegisterData.processOpData.multiplydata.summand, inst->data.DPRegisterData.regType) + (inst->data.DPRegisterData.processOpData.multiplydata.negProd ? -product : product);
|
||||
writeRegister(state, inst->data.DPRegisterData.dest, inst->data.DPRegisterData.regType, sum);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user