From 6161a352e020a68775877a2d61af09c8efc62355 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 21 Oct 2023 23:55:16 +0100 Subject: Implemented vm routines for OP_OR_* --- src/runtime.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/runtime.c') 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)); +} + -- cgit v1.2.3-13-gbd6f