diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:47:05 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 21:47:05 +0000 |
commit | ea715c569eba9cc8310e15ce2e3ded9723a5e8c1 (patch) | |
tree | a154b78ac21ba35854a0564f44ceae3400332a51 /vm/runtime.c | |
parent | cb1cfde0c44b059bdae147475bcde5cccac2a4e5 (diff) | |
download | ovm-ea715c569eba9cc8310e15ce2e3ded9723a5e8c1.tar.gz ovm-ea715c569eba9cc8310e15ce2e3ded9723a5e8c1.tar.bz2 ovm-ea715c569eba9cc8310e15ce2e3ded9723a5e8c1.zip |
Implemented OP_MSIZE in the VM runtime
Diffstat (limited to 'vm/runtime.c')
-rw-r--r-- | vm/runtime.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/vm/runtime.c b/vm/runtime.c index 8a3ce2e..67c288c 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 == 83, "vm_execute: Out of date"); + static_assert(NUMBER_OF_OPCODES == 84, "vm_execute: Out of date"); struct Program *prog = &vm->program; if (prog->ptr >= prog->max) return ERR_END_OF_PROGRAM; @@ -113,7 +113,7 @@ err_t vm_execute(vm_t *vm) OPCODE_IS_TYPE(instruction.opcode, OP_GTE) || OPCODE_IS_TYPE(instruction.opcode, OP_PLUS) || OPCODE_IS_TYPE(instruction.opcode, OP_MULT) || - instruction.opcode == OP_MDELETE) + instruction.opcode == OP_MDELETE || instruction.opcode == OP_MSIZE) { prog->ptr++; return STACK_ROUTINES[instruction.opcode](vm); @@ -817,6 +817,16 @@ err_t vm_mdelete(vm_t *vm) return ERR_OK; } +err_t vm_msize(vm_t *vm) +{ + data_t ptr = {0}; + err_t err = vm_pop_word(vm, &ptr); + if (err) + return err; + page_t *page = (page_t *)ptr.as_word; + return vm_push_word(vm, DWORD(page->available)); +} + #define VM_NOT_TYPE(TYPEL, TYPEU) \ err_t vm_not_##TYPEL(vm_t *vm) \ { \ |