DUP implementation is now part of WORD_ROUTINES
As PUSH_REGISTER and MOV have the same signature of taking a word as input, DUP may as well be part of it. This leads to a larger discussion about how signatures of functions matter: I may need to do a cleanup at some point.
This commit is contained in:
10
vm/runtime.c
10
vm/runtime.c
@@ -68,10 +68,11 @@ err_t vm_execute(vm_t *vm)
|
||||
return PUSH_ROUTINES[instruction.opcode](vm, instruction.operand);
|
||||
}
|
||||
else if (OPCODE_IS_TYPE(instruction.opcode, OP_MOV) ||
|
||||
OPCODE_IS_TYPE(instruction.opcode, OP_PUSH_REGISTER))
|
||||
OPCODE_IS_TYPE(instruction.opcode, OP_PUSH_REGISTER) ||
|
||||
OPCODE_IS_TYPE(instruction.opcode, OP_DUP))
|
||||
{
|
||||
prog->ptr++;
|
||||
return REG_ROUTINES[instruction.opcode](vm, instruction.operand.as_byte);
|
||||
return WORD_ROUTINES[instruction.opcode](vm, instruction.operand.as_word);
|
||||
}
|
||||
else if (OPCODE_IS_TYPE(instruction.opcode, OP_POP))
|
||||
{
|
||||
@@ -94,11 +95,6 @@ err_t vm_execute(vm_t *vm)
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
else if (OPCODE_IS_TYPE(instruction.opcode, OP_DUP))
|
||||
{
|
||||
prog->ptr++;
|
||||
return DUP_ROUTINES[instruction.opcode](vm, instruction.operand.as_word);
|
||||
}
|
||||
else if (OPCODE_IS_TYPE(instruction.opcode, OP_NOT) ||
|
||||
OPCODE_IS_TYPE(instruction.opcode, OP_OR) ||
|
||||
OPCODE_IS_TYPE(instruction.opcode, OP_AND) ||
|
||||
|
||||
Reference in New Issue
Block a user