diff --git a/src/ast.h b/src/ast.h index 12c9b79..68f5e3a 100644 --- a/src/ast.h +++ b/src/ast.h @@ -75,7 +75,7 @@ typedef struct register_ { } register_t; typedef struct opcode_encoding { - uint8_t encoding[32]; + uint8_t buffer[32]; size_t len; } opcode_encoding_t; @@ -89,7 +89,19 @@ struct ast_node { union { register_t reg; number_t number; - opcode_encoding_t encoding; + struct { + bool has_reference; + opcode_encoding_t encoding; + int64_t address; + } instruction; + struct { + int64_t offset; + int64_t address; + operand_size_t size; + } reference; + struct { + int64_t address; + } label; } value; }; diff --git a/src/encoder/encoder.c b/src/encoder/encoder.c index 86c5263..d81a084 100644 --- a/src/encoder/encoder.c +++ b/src/encoder/encoder.c @@ -481,7 +481,7 @@ error_t *encoder_encode_instruction(encoder_t *encoder, return err; // produce the actual encoding output in the NODE_INSTRUCTION value - uint8_t *output = instruction->value.encoding.encoding; + uint8_t *output = instruction->value.instruction.encoding.buffer; size_t output_len = 0; // Handle prefixes @@ -500,7 +500,7 @@ error_t *encoder_encode_instruction(encoder_t *encoder, memcpy(output + output_len, encoding->buffer, encoding->len); output_len += encoding->len; - instruction->value.encoding.len = output_len; + instruction->value.instruction.encoding.len = output_len; return nullptr; } diff --git a/src/main.c b/src/main.c index 17d9335..93e3aff 100644 --- a/src/main.c +++ b/src/main.c @@ -88,7 +88,8 @@ error_t *print_encoding(tokenlist_t *list) { if (node->id != NODE_INSTRUCTION) continue; - print_hex(node->value.encoding.len, node->value.encoding.encoding); + print_hex(node->value.instruction.encoding.len, + node->value.instruction.encoding.buffer); } encoder_free(encoder);