From 4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 21:14:04 +0000 Subject: 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. --- vm/runtime.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'vm/runtime.c') diff --git a/vm/runtime.c b/vm/runtime.c index 0fbea05..ce8281a 100644 --- a/vm/runtime.c +++ b/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) || -- cgit v1.2.3-13-gbd6f