aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index d2c003b..f431dd7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -146,20 +146,26 @@ data_t vm_pop_float(vm_t *vm)
}
typedef void (*push_f)(vm_t *, data_t);
-typedef void (*mov_f)(vm_t *, data_t, word);
-
static const push_f PUSH_ROUTINES[] = {
[OP_PUSH_BYTE] = vm_push_byte,
[OP_PUSH_WORD] = vm_push_word,
[OP_PUSH_FLOAT] = vm_push_float,
};
+typedef void (*mov_f)(vm_t *, data_t, word);
static const mov_f MOV_ROUTINES[] = {
[OP_MOV_BYTE] = vm_mov_byte,
[OP_MOV_WORD] = vm_mov_word,
[OP_MOV_FLOAT] = vm_mov_float,
};
+typedef data_t (*pop_f)(vm_t *);
+static const pop_f POP_ROUTINES[] = {
+ [OP_POP_BYTE] = vm_pop_byte,
+ [OP_POP_WORD] = vm_pop_word,
+ [OP_POP_FLOAT] = vm_pop_float,
+};
+
void vm_execute(vm_t *vm)
{
struct Program *prog = &vm->program;
@@ -178,6 +184,13 @@ void vm_execute(vm_t *vm)
MOV_ROUTINES[instruction.opcode](vm, instruction.operand, instruction.reg);
prog->ptr++;
}
+ else if (OPCODE_IS_POP(instruction.opcode))
+ {
+ // TODO: Figure out what should happen to the result of this pop
+ // routine
+ POP_ROUTINES[instruction.opcode](vm);
+ prog->ptr++;
+ }
else
{
// TODO: Error (Unknown opcode)