diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 22:08:06 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 22:08:06 +0000 |
commit | 90ee9b492db7bf2f8efcf07c30faa719aecec920 (patch) | |
tree | 479cf5323250f62f53e5e0369d8e50314436f618 /vm/runtime.h | |
parent | 0649b3f3804fa1b8924eed9214f33bce6a2c06e8 (diff) | |
download | ovm-90ee9b492db7bf2f8efcf07c30faa719aecec920.tar.gz ovm-90ee9b492db7bf2f8efcf07c30faa719aecec920.tar.bz2 ovm-90ee9b492db7bf2f8efcf07c30faa719aecec920.zip |
Implemented MGET_STACK and MSET_STACK in the runtime
Very easy, they just pop a word then defer to their normal versions.
This is probably the best case where a macro works directly so I
didn't even need to write a function form for them first. One thing
is that then names for the macros are quite bad right now, probably
need renaming.
Diffstat (limited to 'vm/runtime.h')
-rw-r--r-- | vm/runtime.h | 110 |
1 files changed, 72 insertions, 38 deletions
diff --git a/vm/runtime.h b/vm/runtime.h index 9bb61bc..0f8c41e 100644 --- a/vm/runtime.h +++ b/vm/runtime.h @@ -137,6 +137,14 @@ static const word_f WORD_ROUTINES[] = { [OP_MSET_WORD] = vm_mset_word, }; +err_t vm_mset_stack_byte(vm_t *); +err_t vm_mset_stack_hword(vm_t *); +err_t vm_mset_stack_word(vm_t *); + +err_t vm_mget_stack_byte(vm_t *); +err_t vm_mget_stack_hword(vm_t *); +err_t vm_mget_stack_word(vm_t *); + err_t vm_mdelete(vm_t *); err_t vm_msize(vm_t *); @@ -201,44 +209,70 @@ err_t vm_mult_word(vm_t *); typedef err_t (*stack_f)(vm_t *); static const stack_f STACK_ROUTINES[] = { - [OP_MDELETE] = vm_mdelete, [OP_MSIZE] = vm_msize, - - [OP_NOT_BYTE] = vm_not_byte, [OP_NOT_HWORD] = vm_not_hword, - [OP_NOT_WORD] = vm_not_word, - - [OP_OR_BYTE] = vm_or_byte, [OP_OR_HWORD] = vm_or_hword, - [OP_OR_WORD] = vm_or_word, - - [OP_AND_BYTE] = vm_and_byte, [OP_AND_HWORD] = vm_and_hword, - [OP_AND_WORD] = vm_and_word, - - [OP_XOR_BYTE] = vm_xor_byte, [OP_XOR_HWORD] = vm_xor_hword, - [OP_XOR_WORD] = vm_xor_word, - - [OP_EQ_BYTE] = vm_eq_byte, [OP_EQ_HWORD] = vm_eq_hword, - [OP_EQ_WORD] = vm_eq_word, - - [OP_LT_BYTE] = vm_lt_byte, [OP_LT_CHAR] = vm_lt_char, - [OP_LT_INT] = vm_lt_int, [OP_LT_HWORD] = vm_lt_hword, - [OP_LT_LONG] = vm_lt_long, [OP_LT_WORD] = vm_lt_word, - - [OP_LTE_BYTE] = vm_lte_byte, [OP_LTE_CHAR] = vm_lte_char, - [OP_LTE_INT] = vm_lte_int, [OP_LTE_HWORD] = vm_lte_hword, - [OP_LTE_LONG] = vm_lte_long, [OP_LTE_WORD] = vm_lte_word, - - [OP_GT_BYTE] = vm_gt_byte, [OP_GT_CHAR] = vm_gt_char, - [OP_GT_INT] = vm_gt_int, [OP_GT_HWORD] = vm_gt_hword, - [OP_GT_LONG] = vm_gt_long, [OP_GT_WORD] = vm_gt_word, - - [OP_GTE_BYTE] = vm_gte_byte, [OP_GTE_CHAR] = vm_gte_char, - [OP_GTE_INT] = vm_gte_int, [OP_GTE_HWORD] = vm_gte_hword, - [OP_GTE_LONG] = vm_gte_long, [OP_GTE_WORD] = vm_gte_word, - - [OP_PLUS_BYTE] = vm_plus_byte, [OP_PLUS_HWORD] = vm_plus_hword, - [OP_PLUS_WORD] = vm_plus_word, - - [OP_MULT_BYTE] = vm_mult_byte, [OP_MULT_HWORD] = vm_mult_hword, - [OP_MULT_WORD] = vm_mult_word, + [OP_MGET_STACK_BYTE] = vm_mget_stack_byte, + [OP_MGET_STACK_HWORD] = vm_mget_stack_hword, + [OP_MGET_STACK_WORD] = vm_mget_stack_word, + [OP_MSET_STACK_BYTE] = vm_mset_stack_byte, + [OP_MSET_STACK_HWORD] = vm_mset_stack_hword, + [OP_MSET_STACK_WORD] = vm_mset_stack_word, + [OP_MDELETE] = vm_mdelete, + [OP_MSIZE] = vm_msize, + + [OP_NOT_BYTE] = vm_not_byte, + [OP_NOT_HWORD] = vm_not_hword, + [OP_NOT_WORD] = vm_not_word, + + [OP_OR_BYTE] = vm_or_byte, + [OP_OR_HWORD] = vm_or_hword, + [OP_OR_WORD] = vm_or_word, + + [OP_AND_BYTE] = vm_and_byte, + [OP_AND_HWORD] = vm_and_hword, + [OP_AND_WORD] = vm_and_word, + + [OP_XOR_BYTE] = vm_xor_byte, + [OP_XOR_HWORD] = vm_xor_hword, + [OP_XOR_WORD] = vm_xor_word, + + [OP_EQ_BYTE] = vm_eq_byte, + [OP_EQ_HWORD] = vm_eq_hword, + [OP_EQ_WORD] = vm_eq_word, + + [OP_LT_BYTE] = vm_lt_byte, + [OP_LT_CHAR] = vm_lt_char, + [OP_LT_INT] = vm_lt_int, + [OP_LT_HWORD] = vm_lt_hword, + [OP_LT_LONG] = vm_lt_long, + [OP_LT_WORD] = vm_lt_word, + + [OP_LTE_BYTE] = vm_lte_byte, + [OP_LTE_CHAR] = vm_lte_char, + [OP_LTE_INT] = vm_lte_int, + [OP_LTE_HWORD] = vm_lte_hword, + [OP_LTE_LONG] = vm_lte_long, + [OP_LTE_WORD] = vm_lte_word, + + [OP_GT_BYTE] = vm_gt_byte, + [OP_GT_CHAR] = vm_gt_char, + [OP_GT_INT] = vm_gt_int, + [OP_GT_HWORD] = vm_gt_hword, + [OP_GT_LONG] = vm_gt_long, + [OP_GT_WORD] = vm_gt_word, + + [OP_GTE_BYTE] = vm_gte_byte, + [OP_GTE_CHAR] = vm_gte_char, + [OP_GTE_INT] = vm_gte_int, + [OP_GTE_HWORD] = vm_gte_hword, + [OP_GTE_LONG] = vm_gte_long, + [OP_GTE_WORD] = vm_gte_word, + + [OP_PLUS_BYTE] = vm_plus_byte, + [OP_PLUS_HWORD] = vm_plus_hword, + [OP_PLUS_WORD] = vm_plus_word, + + [OP_MULT_BYTE] = vm_mult_byte, + [OP_MULT_HWORD] = vm_mult_hword, + [OP_MULT_WORD] = vm_mult_word, }; #endif |