rewrite opcode/operand splitting logic

This commit is contained in:
EDiasAlberto 2024-06-12 17:34:14 +01:00
parent 53f5b05210
commit 06b18706ed

View File

@ -142,7 +142,6 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr, char *operandList[
} else {
instr->data.BranchData.BranchType = a64inst_CONDITIONAL;
}
generateBranchOperands(instr, opcode, operandList);
} else if(isLoad == 0 || isStore == 0){
//loading/storing instruction; classify operands
char *address = operandList[1];
@ -165,7 +164,6 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr, char *operandList[
//offset is literal, use symbol table and calculate difference
}
}
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
} else {
if(classifyDPInst(operandList)){
@ -209,9 +207,13 @@ void parser_instruction(char asmLine[], a64inst_instruction *instr) {
//duplicated as strtok modifies the input string
char stringptr[strlen(asmLine) + 1];
strcpy(stringptr, asmLine);
char *opcode = strtok(stringptr, " ");
char *operands = strtok(stringptr, "");
char *token;
token = strtok(stringptr, " ");
char opcode[strlen(token)+1];
strcpy(opcode, token);
token = strtok(NULL, "");
char operands[strlen(token)+1];
strcpy(operands, token);
if(strcmp(opcode, ".int") == 0){
//type is directive
@ -228,7 +230,7 @@ void parser_instruction(char asmLine[], a64inst_instruction *instr) {
} else {
//type is instruction
int operandCount = 0;
char *operandList[4];
char *operandList[5];
//generate list of operands
tokeniseOperands(operands, &operandCount, operandList, &numOperands);
//categorise instruction type from opcode and operands