fix directive operand parsing

This commit is contained in:
EDiasAlberto 2024-06-14 21:15:19 +01:00
parent ffa798b266
commit 8bea0d6a6d

View File

@ -212,8 +212,15 @@ void parse_instruction(char asmLine[], a64inst_instruction *instr) {
if(strcmp(opcode, ".int") == 0){
// Directive
instr->type = a64inst_DIRECTIVE;
instr->data.DirectiveData.value = getOperandNumber(tokens[1]);
char *intValue = tokens[1];
char *endptr;
if(strncmp(intValue, "0x", 2) == 0) {
intValue += 2;
instr->data.DirectiveData.value = strtol(intValue, &endptr, 16);
} else {
instr->data.DirectiveData.value = strtol(tokens[1], &endptr, 10);
}
} else if(opcode[strlen(opcode)-1]== ':') {
// Label
instr->type = a64inst_LABEL;