diff --git a/src/parser.c b/src/parser.c index 4cb939c..d518e0c 100644 --- a/src/parser.c +++ b/src/parser.c @@ -25,6 +25,7 @@ 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"}; static const char *LOGIC_OPCODES[] = {"and", "ands", "bic", "bics", "eor", "eon", "orr", "orn"}; +static const char *ZERO_REGISTER_ALIAS[] = {"xzr", "wzr"}; static const char *ALIAS_OPCODES[] = {"cmp", "cmn", "neg", "negs", "tst", "mvn", "mov"}; static char *ALIAS_TARGET_OPCODES[] = {"subs", "adds", "sub", "subs", "ands", "orn", "orr"}; @@ -172,6 +173,10 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr, char *tokens[], in //takes inputted char array and returns the integer of the operand, skipping the first character //e.g. for a passed "R32", it skips the 'R' and returns 32 int getOperandNumber(char *operand){ + if (isStringIn(operand, ZERO_REGISTER_ALIAS, 2)) { + return ZERO_REGISTER; + } + char operandCpy[strlen(operand)]; strcpy(operandCpy, operand+1); char **endptr = NULL;