From c6ff7e1c4e4405e10076a0335cb713250df0217f Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Wed, 12 Jun 2024 16:29:29 +0100 Subject: [PATCH] comment getOperandNumber --- src/parser.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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