aboutsummaryrefslogtreecommitdiff
path: root/include/program.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/program.h')
-rw-r--r--include/program.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/include/program.h b/include/program.h
index f251fbc..3fc69fa 100644
--- a/include/program.h
+++ b/include/program.h
@@ -3,6 +3,7 @@
#include "std/buffer.h"
#include "bytecode/bytecode.h"
+#include "asm/x86_64.h"
#define AMAL_PROGRAM_OK 0
#define AMAL_PROGRAM_INVALID_HEADER -1
@@ -14,18 +15,36 @@
#define AMAL_PROGRAM_INVALID_STRINGS_SIZE -7
#define AMAL_PROGRAM_STRING_ALLOC_FAILURE -8
#define AMAL_PROGRAM_INVALID_INSTRUCTIONS_SIZE -9
+#define AMAL_PROGRAM_INVALID_INSTRUCTION -10
+#define AMAL_PROGRAM_INSTRUCTION_INVALID_INTERMEDIATE_INDEX -11
+#define AMAL_PROGRAM_INSTRUCTION_INVALID_DATA_INDEX -12
+#define AMAL_PROGRAM_INSTRUCTION_STACK_OVERFLOW -13
+#define AMAL_PROGRAM_INSTRUCTION_STACK_OOM -14
+#define AMAL_PROGRAM_INSTRUCTION_ILLEGAL_JUMP_TARGET -15
#define AMAL_PROGRAM_MAGIC_NUMBER (u32)0xdec05eba
#define AMAL_PROGRAM_MAJOR_VERSION 1
#define AMAL_PROGRAM_MINOR_VERSION 0
#define AMAL_PROGRAM_PATCH_VERSION 0
+#define AMAL_PROGRAM_NUM_REGISTERS 256
+
typedef struct {
Buffer/*<...>*/ data;
- Buffer/*<u32>*/ string_indices;
- char *intermediates_start;
- char *strings_start;
+ u32 *string_indices;
+ char *intermediates_start; /* Reference inside @data */
+ char *strings_start; /* Reference inside @data */
usize read_index;
+
+ u16 num_strings;
+ u16 num_intermediates;
+
+ u64 reg[AMAL_PROGRAM_NUM_REGISTERS];
+ u64 *stack;
+ usize stack_size;
+ usize stack_index;
+
+ Asm asm;
} amal_program;
CHECK_RESULT int amal_program_init(amal_program *self);