diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:14:04 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:14:04 +0000 |
commit | 4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b (patch) | |
tree | d4bd757e7a7824c11d0a1d7fe5da217f9fd65b4b /vm/runtime.h | |
parent | a5afaee3d027a66148b0f184d401ed76e6c0f8ff (diff) | |
download | ovm-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.h')
-rw-r--r-- | vm/runtime.h | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/vm/runtime.h b/vm/runtime.h index 6c6042a..c4d28d8 100644 --- a/vm/runtime.h +++ b/vm/runtime.h @@ -96,26 +96,23 @@ err_t vm_mov_byte(vm_t *, word); err_t vm_mov_hword(vm_t *, word); err_t vm_mov_word(vm_t *, word); -typedef err_t (*reg_f)(vm_t *, word); -static const reg_f REG_ROUTINES[] = { +err_t vm_dup_byte(vm_t *, word); +err_t vm_dup_hword(vm_t *, word); +err_t vm_dup_word(vm_t *, word); + +typedef err_t (*word_f)(vm_t *, word); +static const word_f WORD_ROUTINES[] = { [OP_PUSH_REGISTER_BYTE] = vm_push_byte_register, [OP_PUSH_REGISTER_HWORD] = vm_push_hword_register, [OP_PUSH_REGISTER_WORD] = vm_push_word_register, [OP_MOV_BYTE] = vm_mov_byte, [OP_MOV_HWORD] = vm_mov_hword, [OP_MOV_WORD] = vm_mov_word, + [OP_DUP_BYTE] = vm_dup_byte, + [OP_DUP_HWORD] = vm_dup_hword, + [OP_DUP_WORD] = vm_dup_word, }; -err_t vm_dup_byte(vm_t *, word); -err_t vm_dup_hword(vm_t *, word); -err_t vm_dup_word(vm_t *, word); - -typedef err_t (*dup_f)(vm_t *, word); -static const dup_f DUP_ROUTINES[] = { - [OP_DUP_BYTE] = vm_dup_byte, - [OP_DUP_HWORD] = vm_dup_hword, - [OP_DUP_WORD] = vm_dup_word, -}; err_t vm_not_byte(vm_t *); err_t vm_not_hword(vm_t *); |