diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-15 21:13:15 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-15 21:13:15 +0100 |
commit | 2490966554a378af4a48b51d5e7eb717a570285a (patch) | |
tree | d947d188809afc02440d71453bff56f3a721a294 /src/main.c | |
parent | 6927557d3f31cd5a75269bb058c5c75022e4f524 (diff) | |
download | ovm-2490966554a378af4a48b51d5e7eb717a570285a.tar.gz ovm-2490966554a378af4a48b51d5e7eb717a570285a.tar.bz2 ovm-2490966554a378af4a48b51d5e7eb717a570285a.zip |
Implemented vm_execute for pop routines
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -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) |