aboutsummaryrefslogtreecommitdiff
path: root/vm/runtime.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 21:14:04 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-01 21:14:04 +0000
commit4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b (patch)
treed4bd757e7a7824c11d0a1d7fe5da217f9fd65b4b /vm/runtime.c
parenta5afaee3d027a66148b0f184d401ed76e6c0f8ff (diff)
downloadovm-4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b.tar.gz
ovm-4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b.tar.bz2
ovm-4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b.zip
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.
Diffstat (limited to 'vm/runtime.c')
-rw-r--r--vm/runtime.c10
1 files changed, 3 insertions, 7 deletions
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) ||