add hex number handling to getoperandnumebrs
This commit is contained in:
parent
eed22f64d9
commit
873c0b60cb
10
src/parser.c
10
src/parser.c
@ -21,6 +21,7 @@ static const char *SINGLE_TRANSFER_OPCODES[] = {"ldr", "str"};
|
||||
static const char *WIDE_MOV_OPCODES[] = {"movn", "movz", "movz", "movk"};
|
||||
static const char *ARITHMETIC_OPCODES[] = {"add", "adds", "sub", "subs"};
|
||||
static const char *MULTIPLY_OPCODES[] = {"mul", "madd", "msub", "mneg"};
|
||||
static const char *SHIFT_TYPE_OPCODES[] = {"lsl", "lsr", "asr", "ror"};
|
||||
|
||||
a64inst_instruction *parse(char **asmLines, int lineCount) {
|
||||
a64inst_instruction *instructions = malloc(sizeof(a64inst_instruction) * lineCount);
|
||||
@ -165,7 +166,14 @@ int getOperandNumber(char *operand){
|
||||
char operandCpy[strlen(operand)];
|
||||
strcpy(operandCpy, operand+1);
|
||||
char **endptr = NULL;
|
||||
int number = strtol(operandCpy, endptr, 10);
|
||||
int number;
|
||||
if(strncmp(operandCpy, "0x", 2)==0){
|
||||
//hex value
|
||||
strcpy(operandCpy, operand+3);
|
||||
number = strtol(operandCpy, endptr, 16);
|
||||
} else {
|
||||
number = strtol(operandCpy, endptr, 10);
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user