| @@ -90,14 +90,8 @@ static ErrorInfo* resolve_symbols(AssemblerState *state) | |||||
| return ei; | return ei; | ||||
| } | } | ||||
| if (inst->loc.length == 3) { | |||||
| inst->b2 = symbol->offset & 0xFF; | |||||
| inst->b3 = symbol->offset >> 8; | |||||
| } else { | |||||
| inst->b3 = symbol->offset & 0xFF; | |||||
| inst->b4 = symbol->offset >> 8; | |||||
| } | |||||
| inst->bytes[inst->loc.length - 2] = symbol->offset & 0xFF; | |||||
| inst->bytes[inst->loc.length - 1] = symbol->offset >> 8; | |||||
| free(inst->symbol); | free(inst->symbol); | ||||
| inst->symbol = NULL; | inst->symbol = NULL; | ||||
| } | } | ||||
| @@ -88,6 +88,7 @@ void asm_instructions_free(ASMInstruction *inst) | |||||
| { | { | ||||
| while (inst) { | while (inst) { | ||||
| ASMInstruction *temp = inst->next; | ASMInstruction *temp = inst->next; | ||||
| free(inst->bytes); | |||||
| if (inst->symbol) | if (inst->symbol) | ||||
| free(inst->symbol); | free(inst->symbol); | ||||
| free(inst); | free(inst); | ||||
| @@ -102,7 +103,7 @@ void asm_data_free(ASMData *data) | |||||
| { | { | ||||
| while (data) { | while (data) { | ||||
| ASMData *temp = data->next; | ASMData *temp = data->next; | ||||
| free(data->data); | |||||
| free(data->bytes); | |||||
| free(data); | free(data); | ||||
| data = temp; | data = temp; | ||||
| } | } | ||||
| @@ -40,7 +40,7 @@ typedef struct { | |||||
| struct ASMInstruction { | struct ASMInstruction { | ||||
| ASMLocation loc; | ASMLocation loc; | ||||
| uint8_t b1, b2, b3, b4; | |||||
| uint8_t *bytes; | |||||
| char *symbol; | char *symbol; | ||||
| const ASMLine *line; | const ASMLine *line; | ||||
| struct ASMInstruction *next; | struct ASMInstruction *next; | ||||
| @@ -49,7 +49,7 @@ typedef struct ASMInstruction ASMInstruction; | |||||
| struct ASMData { | struct ASMData { | ||||
| ASMLocation loc; | ASMLocation loc; | ||||
| uint8_t *data; | |||||
| uint8_t *bytes; | |||||
| struct ASMData *next; | struct ASMData *next; | ||||
| }; | }; | ||||
| typedef struct ASMData ASMData; | typedef struct ASMData ASMData; | ||||
| @@ -155,7 +155,7 @@ static ErrorInfo* parse_data( | |||||
| data->loc.offset = offset; | data->loc.offset = offset; | ||||
| data->loc.length = 6; | data->loc.length = 6; | ||||
| data->data = (uint8_t*) strdup("foobar"); | |||||
| data->bytes = (uint8_t*) strdup("foobar"); | |||||
| data->next = NULL; | data->next = NULL; | ||||
| *data_ptr = data; | *data_ptr = data; | ||||
| @@ -182,7 +182,8 @@ static ErrorInfo* parse_instruction( | |||||
| inst->loc.offset = offset; | inst->loc.offset = offset; | ||||
| inst->loc.length = 1; | inst->loc.length = 1; | ||||
| inst->b1 = 0x3C; | |||||
| uint8_t tmp = 0x3C; | |||||
| inst->bytes = memcpy(malloc(1), &tmp, 1); | |||||
| inst->symbol = NULL; | inst->symbol = NULL; | ||||
| inst->line = line; | inst->line = line; | ||||
| inst->next = NULL; | inst->next = NULL; | ||||