diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-21 23:55:16 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-21 23:55:16 +0100 |
commit | 6161a352e020a68775877a2d61af09c8efc62355 (patch) | |
tree | ce1e7dc8abf558218b220f77bbc6c578b592086a | |
parent | ae7f0efc858510034dddee5bd1a02a6ec3788c32 (diff) | |
download | ovm-6161a352e020a68775877a2d61af09c8efc62355.tar.gz ovm-6161a352e020a68775877a2d61af09c8efc62355.tar.bz2 ovm-6161a352e020a68775877a2d61af09c8efc62355.zip |
Implemented vm routines for OP_OR_*
-rw-r--r-- | src/runtime.c | 30 | ||||
-rw-r--r-- | src/runtime.h | 10 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/runtime.c b/src/runtime.c index d938c46..a57dc2f 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -366,3 +366,33 @@ void vm_not_word(vm_t *vm) vm_push_word(vm, DWORD(!a)); } +void vm_or_byte(vm_t *vm) +{ + if (vm->stack.ptr < 2) + // TODO: Error STACK_UNDERFLOW + return; + byte a = vm_pop_byte(vm).as_byte; + byte b = vm_pop_byte(vm).as_byte; + vm_push_byte(vm, DBYTE(a | b)); +} + +void vm_or_hword(vm_t *vm) +{ + if (vm->stack.ptr < (HWORD_SIZE * 2)) + // TODO: Error STACK_UNDERFLOW + return; + hword a = vm_pop_hword(vm).as_hword; + hword b = vm_pop_hword(vm).as_hword; + vm_push_hword(vm, DHWORD(a | b)); +} + +void vm_or_word(vm_t *vm) +{ + if (vm->stack.ptr < (WORD_SIZE * 2)) + // TODO: Error STACK_UNDERFLOW + return; + word a = vm_pop_word(vm).as_word; + word b = vm_pop_word(vm).as_word; + vm_push_word(vm, DWORD(a | b)); +} + diff --git a/src/runtime.h b/src/runtime.h index 4a2f849..d757e36 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -111,4 +111,14 @@ static const not_f NOT_ROUTINES[] = { [OP_NOT_WORD] = vm_not_word, }; +void vm_or_byte(vm_t *); +void vm_or_hword(vm_t *); +void vm_or_word(vm_t *); +typedef void (*or_f)(vm_t *); +static const or_f OR_ROUTINES[] = { + [OP_OR_BYTE] = vm_or_byte, + [OP_OR_HWORD] = vm_or_hword, + [OP_OR_WORD] = vm_or_word, +}; + #endif |