diff --git a/src/parser.c b/src/parser.c index 97eef8d..cd7c9ed 100644 --- a/src/parser.c +++ b/src/parser.c @@ -18,6 +18,8 @@ // - ASK ABOUT OFFSET CALCULATION // - CREATE FUNC TO TIDY UP OPERANDS IN DP +//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){ char *operandCpy = strcpy(operandCpy, operand); operandCpy++; @@ -159,11 +161,7 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr, char *operandList[ instr->type = a64inst_LOADLITERAL; if(operandList[0][0] =='#'){ //offset is immediate - char *immOffset = NULL; - immOffset = strcpy(immOffset, operandList[0]); - immOffset++; - char *endptr = NULL; - int offset = strtol(immOffset, &endptr, 10); + int offset = getOperandNumber(operandList[0]); instr->data.SingleTransferData.processOpData.loadLiteralData.offset = offset; } else { //offset is literal, use symbol table and calculate difference