comment getOperandNumber

This commit is contained in:
EDiasAlberto 2024-06-12 16:29:29 +01:00
parent f32304afb7
commit c6ff7e1c4e

View File

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