@@ -24,6 +24,7 @@ static ErrorInfo* tokenize(AssemblerState *state) | |||||
// verify no instructions clash with header offset | // verify no instructions clash with header offset | ||||
// if rom size is set, verify nothing overflows | // if rom size is set, verify nothing overflows | ||||
(void) state; | |||||
return NULL; | return NULL; | ||||
} | } | ||||
@@ -45,6 +46,7 @@ static ErrorInfo* resolve_defaults(AssemblerState *state) | |||||
// if (!state.header.rom_size) | // if (!state.header.rom_size) | ||||
// set to actual rom size | // set to actual rom size | ||||
(void) state; | |||||
return NULL; | return NULL; | ||||
} | } | ||||
@@ -58,6 +60,7 @@ static ErrorInfo* resolve_symbols(AssemblerState *state) | |||||
{ | { | ||||
// TODO | // TODO | ||||
(void) state; | |||||
return NULL; | return NULL; | ||||
} | } | ||||
@@ -98,10 +101,7 @@ size_t assemble(const LineBuffer *source, uint8_t **binary_ptr, ErrorInfo **ei_p | |||||
if ((error_info = preprocess(&state, source))) | if ((error_info = preprocess(&state, source))) | ||||
goto error; | goto error; | ||||
if (!(state.symtable = malloc(sizeof(ASMSymbolTable)))) | |||||
OUT_OF_MEMORY() | |||||
for (size_t bucket = 0; bucket < SYMBOL_TABLE_BUCKETS; bucket++) | |||||
state.symtable->buckets[bucket] = NULL; | |||||
asm_symtable_init(&state.symtable); | |||||
if ((error_info = tokenize(&state))) | if ((error_info = tokenize(&state))) | ||||
goto error; | goto error; | ||||
@@ -5,6 +5,7 @@ | |||||
#include "state.h" | #include "state.h" | ||||
#include "io.h" | #include "io.h" | ||||
#include "../logging.h" | |||||
#include "../util.h" | #include "../util.h" | ||||
#define DEFAULT_HEADER_OFFSET 0x7FF0 | #define DEFAULT_HEADER_OFFSET 0x7FF0 | ||||
@@ -31,6 +32,21 @@ void state_init(AssemblerState *state) | |||||
} | } | ||||
/* | /* | ||||
Initialize an ASMSymbolTable and place it in *symtable_ptr. | |||||
*/ | |||||
void asm_symtable_init(ASMSymbolTable **symtable_ptr) | |||||
{ | |||||
ASMSymbolTable *symtable; | |||||
if (!(symtable = malloc(sizeof(ASMSymbolTable)))) | |||||
OUT_OF_MEMORY() | |||||
for (size_t bucket = 0; bucket < SYMBOL_TABLE_BUCKETS; bucket++) | |||||
symtable->buckets[bucket] = NULL; | |||||
*symtable_ptr = symtable; | |||||
} | |||||
/* | |||||
Deallocate an ASMLine list. | Deallocate an ASMLine list. | ||||
*/ | */ | ||||
void asm_lines_free(ASMLine *line) | void asm_lines_free(ASMLine *line) | ||||
@@ -71,6 +71,7 @@ typedef struct { | |||||
/* Functions */ | /* Functions */ | ||||
void state_init(AssemblerState*); | void state_init(AssemblerState*); | ||||
void asm_symtable_init(ASMSymbolTable**); | |||||
void asm_lines_free(ASMLine*); | void asm_lines_free(ASMLine*); | ||||
void asm_includes_free(ASMInclude*); | void asm_includes_free(ASMInclude*); | ||||
void asm_instructions_free(ASMInstruction*); | void asm_instructions_free(ASMInstruction*); | ||||