aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:27:26 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-15 21:27:26 +0100
commitf513e90f001f1957d5ae5baba102a0b7b611dcfb (patch)
treea80cc7283dfb9e4b2669e49457d2f003a74265f3
parent744cc7acf78e99775b037d7a7b3e0d193ce410ff (diff)
downloadovm-f513e90f001f1957d5ae5baba102a0b7b611dcfb.tar.gz
ovm-f513e90f001f1957d5ae5baba102a0b7b611dcfb.tar.bz2
ovm-f513e90f001f1957d5ae5baba102a0b7b611dcfb.zip
Implemented vm_push_*_register routines
-rw-r--r--src/main.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index c0a2e00..8033844 100644
--- a/src/main.c
+++ b/src/main.c
@@ -87,6 +87,39 @@ void vm_push_float(vm_t *vm, data_t f)
vm->stack.ptr += FLOAT_SIZE;
}
+void vm_push_byte_register(vm_t *vm, word reg)
+{
+ if (reg >= VM_BYTE_REGISTERS)
+ // TODO: Error (reg is not a valid byte register)
+ return;
+ else if (vm->stack.ptr >= vm->stack.max)
+ // TODO: Error STACK_OVERFLOW
+ return;
+ vm_push_byte(vm, DBYTE(vm->registers.b[reg]));
+}
+
+void vm_push_word_register(vm_t *vm, word reg)
+{
+ if (reg >= VM_WORD_REGISTERS)
+ // TODO: Error (reg is not a valid word register)
+ return;
+ else if (vm->stack.ptr >= vm->stack.max)
+ // TODO: Error STACK_OVERFLOW
+ return;
+ vm_push_word(vm, DWORD(vm->registers.w[reg]));
+}
+
+void vm_push_float_register(vm_t *vm, word reg)
+{
+ if (reg >= VM_FLOAT_REGISTERS)
+ // TODO: Error (reg is not a valid float register)
+ return;
+ else if (vm->stack.ptr >= vm->stack.max)
+ // TODO: Error STACK_OVERFLOW
+ return;
+ vm_push_float(vm, DFLOAT(vm->registers.f[reg]));
+}
+
void vm_mov_byte(vm_t *vm, data_t b, word reg)
{
if (reg >= VM_BYTE_REGISTERS)