From 4e64f1fe235ffaed6f2eb6fdb228b480c4dfcb1b Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Wed, 1 Nov 2023 21:14:04 +0000 Subject: 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. --- vm/runtime.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'vm/runtime.h') 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 *); -- cgit v1.2.3-13-gbd6f