aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-21 23:54:59 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-21 23:54:59 +0100
commitae7f0efc858510034dddee5bd1a02a6ec3788c32 (patch)
tree1807926100d46a27c68d1b9b153f6363de85defd /src/runtime.c
parentba57523f3ecba69e628a7a811f258b652cf48615 (diff)
downloadovm-ae7f0efc858510034dddee5bd1a02a6ec3788c32.tar.gz
ovm-ae7f0efc858510034dddee5bd1a02a6ec3788c32.tar.bz2
ovm-ae7f0efc858510034dddee5bd1a02a6ec3788c32.zip
Implemented vm routines for OP_NOT_*
Diffstat (limited to 'src/runtime.c')
-rw-r--r--src/runtime.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/runtime.c b/src/runtime.c
index 57101e0..d938c46 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -335,3 +335,34 @@ data_t vm_pop_word(vm_t *vm)
}
return DWORD(w);
}
+
+void vm_not_byte(vm_t *vm)
+{
+ if (vm->stack.ptr == 0)
+ // TODO: Error STACK_UNDERFLOW
+ return;
+
+ byte a = vm_pop_byte(vm).as_byte;
+ vm_push_byte(vm, DBYTE(!a));
+}
+
+void vm_not_hword(vm_t *vm)
+{
+ if (vm->stack.ptr < HWORD_SIZE)
+ // TODO: Error STACK_UNDERFLOW
+ return;
+
+ hword a = vm_pop_hword(vm).as_hword;
+ vm_push_hword(vm, DHWORD(!a));
+}
+
+void vm_not_word(vm_t *vm)
+{
+ if (vm->stack.ptr < WORD_SIZE)
+ // TODO: Error STACK_UNDERFLOW
+ return;
+
+ word a = vm_pop_word(vm).as_word;
+ vm_push_word(vm, DWORD(!a));
+}
+