aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime.h')
-rw-r--r--src/runtime.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/runtime.h b/src/runtime.h
index f512992..e588541 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -19,17 +19,13 @@
#include "./base.h"
#include "./inst.h"
-#define VM_BYTE_REGISTERS 8
-#define VM_WORD_REGISTERS 8
-#define VM_FLOAT_REGISTERS 8
+#define VM_REGISTERS 8
typedef struct
{
struct Registers
{
word ret;
- byte b[VM_BYTE_REGISTERS];
- word w[VM_WORD_REGISTERS];
- f64 f[VM_FLOAT_REGISTERS];
+ word reg[VM_REGISTERS];
} registers;
struct Stack
{
@@ -43,6 +39,10 @@ typedef struct
} program;
} vm_t;
+#define VM_REG_BYTE(REG) ((REG)&0b11111111)
+#define VM_REG_HWORD(REG) ((REG)&0b11111111111111111111111111111111)
+#define VM_REG_WORD(REG) ((REG))
+
void vm_execute(vm_t *);
void vm_load_stack(vm_t *, byte *, size_t);
@@ -56,47 +56,47 @@ void vm_print_program(vm_t *, FILE *);
void vm_print_all(vm_t *, FILE *);
void vm_push_byte(vm_t *, data_t);
+void vm_push_hword(vm_t *, data_t);
void vm_push_word(vm_t *, data_t);
-void vm_push_float(vm_t *, data_t);
typedef void (*push_f)(vm_t *, data_t);
static const push_f PUSH_ROUTINES[] = {
[OP_PUSH_BYTE] = vm_push_byte,
+ [OP_PUSH_HWORD] = vm_push_hword,
[OP_PUSH_WORD] = vm_push_word,
- [OP_PUSH_FLOAT] = vm_push_float,
};
-void vm_push_byte_register(vm_t *, word);
-void vm_push_word_register(vm_t *, word);
-void vm_push_float_register(vm_t *, word);
+void vm_push_byte_register(vm_t *, byte);
+void vm_push_hword_register(vm_t *, byte);
+void vm_push_word_register(vm_t *, byte);
-typedef void (*push_reg_f)(vm_t *, word);
+typedef void (*push_reg_f)(vm_t *, byte);
static const push_reg_f PUSH_REG_ROUTINES[] = {
- [OP_PUSH_BYTE_REGISTER] = vm_push_byte_register,
- [OP_PUSH_WORD_REGISTER] = vm_push_word_register,
- [OP_PUSH_FLOAT_REGISTER] = vm_push_float_register,
+ [OP_PUSH_REGISTER_BYTE] = vm_push_byte_register,
+ [OP_PUSH_REGISTER_HWORD] = vm_push_hword_register,
+ [OP_PUSH_REGISTER_WORD] = vm_push_word_register,
};
-data_t vm_mov_byte(vm_t *, word);
-data_t vm_mov_word(vm_t *, word);
-data_t vm_mov_float(vm_t *, word);
+data_t vm_mov_byte(vm_t *, byte);
+data_t vm_mov_hword(vm_t *, byte);
+data_t vm_mov_word(vm_t *, byte);
-typedef data_t (*mov_f)(vm_t *, word);
+typedef data_t (*mov_f)(vm_t *, byte);
static const mov_f MOV_ROUTINES[] = {
[OP_MOV_BYTE] = vm_mov_byte,
+ [OP_MOV_HWORD] = vm_mov_hword,
[OP_MOV_WORD] = vm_mov_word,
- [OP_MOV_FLOAT] = vm_mov_float,
};
data_t vm_pop_byte(vm_t *);
+data_t vm_pop_hword(vm_t *);
data_t vm_pop_word(vm_t *);
-data_t vm_pop_float(vm_t *);
typedef data_t (*pop_f)(vm_t *);
static const pop_f POP_ROUTINES[] = {
[OP_POP_BYTE] = vm_pop_byte,
+ [OP_POP_HWORD] = vm_pop_hword,
[OP_POP_WORD] = vm_pop_word,
- [OP_POP_FLOAT] = vm_pop_float,
};
#endif