diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 22:56:24 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 22:56:24 +0000 |
commit | ac3270777b3f9a13bb94c99e9fad041775d3f070 (patch) | |
tree | 3bd5d66bafae507077ccd4a1cdf29328489c66ef /vm/runtime.c | |
parent | 46e5abbac9d8e4d9257e59cd0f8b73f509e4a512 (diff) | |
download | ovm-ac3270777b3f9a13bb94c99e9fad041775d3f070.tar.gz ovm-ac3270777b3f9a13bb94c99e9fad041775d3f070.tar.bz2 ovm-ac3270777b3f9a13bb94c99e9fad041775d3f070.zip |
Implemented OP_MALLOC_STACK and OP_SUB in the runtime
Diffstat (limited to 'vm/runtime.c')
-rw-r--r-- | vm/runtime.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vm/runtime.c b/vm/runtime.c index 1f5396a..5d5333b 100644 --- a/vm/runtime.c +++ b/vm/runtime.c @@ -60,7 +60,7 @@ const char *err_as_cstr(err_t err) err_t vm_execute(vm_t *vm) { - static_assert(NUMBER_OF_OPCODES == 90, "vm_execute: Out of date"); + static_assert(NUMBER_OF_OPCODES == 96, "vm_execute: Out of date"); struct Program *prog = &vm->program; if (prog->ptr >= prog->max) return ERR_END_OF_PROGRAM; @@ -112,7 +112,9 @@ err_t vm_execute(vm_t *vm) OPCODE_IS_TYPE(instruction.opcode, OP_GT) || OPCODE_IS_TYPE(instruction.opcode, OP_GTE) || OPCODE_IS_TYPE(instruction.opcode, OP_PLUS) || + OPCODE_IS_TYPE(instruction.opcode, OP_SUB) || OPCODE_IS_TYPE(instruction.opcode, OP_MULT) || + OPCODE_IS_TYPE(instruction.opcode, OP_MALLOC_STACK) || OPCODE_IS_TYPE(instruction.opcode, OP_MSET_STACK) || OPCODE_IS_TYPE(instruction.opcode, OP_MGET_STACK) || instruction.opcode == OP_MDELETE || instruction.opcode == OP_MSIZE) @@ -817,6 +819,9 @@ err_t vm_pop_word(vm_t *vm, data_t *ret) return vm_##ACTION##_##TYPE(vm, n.as_word); \ } +VM_MEMORY_STACK_CONSTR(malloc, byte) +VM_MEMORY_STACK_CONSTR(malloc, hword) +VM_MEMORY_STACK_CONSTR(malloc, word) VM_MEMORY_STACK_CONSTR(mset, byte) VM_MEMORY_STACK_CONSTR(mset, hword) VM_MEMORY_STACK_CONSTR(mset, word) @@ -904,6 +909,10 @@ VM_SAME_TYPE(plus, +, byte, BYTE) VM_SAME_TYPE(plus, +, hword, HWORD) VM_SAME_TYPE(plus, +, word, WORD) +VM_SAME_TYPE(sub, -, byte, BYTE) +VM_SAME_TYPE(sub, -, hword, HWORD) +VM_SAME_TYPE(sub, -, word, WORD) + VM_SAME_TYPE(mult, *, byte, BYTE) VM_SAME_TYPE(mult, *, hword, HWORD) VM_SAME_TYPE(mult, *, word, WORD) |