From 1f28c3c733ea3ae4234bff91e1c55e61b1ee3e96 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Jul 2019 01:25:05 +0200 Subject: Starting on asm, implementing extern function call so progress is visible --- include/program.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'include/program.h') 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/**/ 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); -- cgit v1.2.3