diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 17:01:15 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-22 17:34:30 +0100 |
commit | 47c7d6baf7d39da5e2683edc3674494fcd3874ba (patch) | |
tree | da2e739db9dc9c4ab70656dc005c8a5747bb2b41 /src/runtime.h | |
parent | 95723f36d2aa7e1bcd343b2e072c0bcf28a3b1b5 (diff) | |
download | ovm-47c7d6baf7d39da5e2683edc3674494fcd3874ba.tar.gz ovm-47c7d6baf7d39da5e2683edc3674494fcd3874ba.tar.bz2 ovm-47c7d6baf7d39da5e2683edc3674494fcd3874ba.zip |
Store the result of OP_POP in the last register as a word
Instead of making routines to handle data in the `ret` register, just
store the result of POP into the last word register.
This means we are no longer using vm_pop_* or POP_ROUTINES for the
vm_execute script on OP_POP: instead we'll just use vm_mov_* which
automatically pops the datum for us, while moving the datum to the
last register.
Diffstat (limited to 'src/runtime.h')
-rw-r--r-- | src/runtime.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/runtime.h b/src/runtime.h index 2ec01df..3e4c295 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -24,7 +24,9 @@ typedef struct { struct Registers { + // Used for internal word ret; + // General registers word reg[VM_REGISTERS]; } registers; struct Stack @@ -50,12 +52,15 @@ void vm_load_stack(vm_t *, byte *, size_t); void vm_load_program(vm_t *, inst_t *, size_t); // Print routines +#define VM_PRINT_PROGRAM_EXCERPT 5 void vm_print_registers(vm_t *, FILE *); void vm_print_stack(vm_t *, FILE *); -#define VM_PRINT_PROGRAM_EXCERPT 5 void vm_print_program(vm_t *, FILE *); void vm_print_all(vm_t *, FILE *); +data_t vm_peek(vm_t *, data_type_t); + +// Execution routines void vm_push_byte(vm_t *, data_t); void vm_push_hword(vm_t *, data_t); void vm_push_word(vm_t *, data_t); @@ -93,13 +98,6 @@ data_t vm_pop_byte(vm_t *); data_t vm_pop_hword(vm_t *); data_t vm_pop_word(vm_t *); -typedef data_t (*pop_f)(vm_t *); -static const pop_f POP_ROUTINES[] = { - [OP_POP_BYTE] = vm_pop_byte, - [OP_POP_HWORD] = vm_pop_hword, - [OP_POP_WORD] = vm_pop_word, -}; - void vm_not_byte(vm_t *); void vm_not_hword(vm_t *); void vm_not_word(vm_t *); |