Merge branch 'assembler-e' into 'assembler-s'
Assembler e See merge request lab2324_summer/armv8_43!13
This commit is contained in:
commit
b3a108d3a3
20
src/parser.c
20
src/parser.c
@ -18,6 +18,17 @@
|
|||||||
// - 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){
|
||||||
|
char *operandCpy = NULL;
|
||||||
|
strcpy(operandCpy, operand);
|
||||||
|
operandCpy++;
|
||||||
|
char **endptr = NULL;
|
||||||
|
int number = strtol(operandCpy, endptr, 10);
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
int isOperandRegister(char *operand){
|
int isOperandRegister(char *operand){
|
||||||
return((strcmp(&(operand[0]), "x")==0) || (strcmp(&(operand[0]), "w")==0));
|
return((strcmp(&(operand[0]), "x")==0) || (strcmp(&(operand[0]), "w")==0));
|
||||||
}
|
}
|
||||||
@ -64,7 +75,6 @@ void generateLoadStoreOperands(a64inst_instruction *instr, char *opcode, char *o
|
|||||||
}
|
}
|
||||||
char *endptr;
|
char *endptr;
|
||||||
instr->data.SingleTransferData.target = strtol(&(operandList[0][0])+1, &endptr, 10);
|
instr->data.SingleTransferData.target = strtol(&(operandList[0][0])+1, &endptr, 10);
|
||||||
calcluateAddressFormat(instr, operandList, numOperands);
|
|
||||||
break;
|
break;
|
||||||
case a64inst_LOADLITERAL:
|
case a64inst_LOADLITERAL:
|
||||||
break;
|
break;
|
||||||
@ -151,16 +161,13 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(classifyDPInst(operandList)){
|
if(classifyDPInst(operandList)){
|
||||||
@ -235,6 +242,7 @@ void parser_instruction(char asmLine[], a64inst_instruction *instr) {
|
|||||||
break;
|
break;
|
||||||
case a64inst_SINGLETRANSFER:
|
case a64inst_SINGLETRANSFER:
|
||||||
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
|
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
|
||||||
|
calcluateAddressFormat(instr, operandList, numOperands);
|
||||||
break;
|
break;
|
||||||
case a64inst_LOADLITERAL:
|
case a64inst_LOADLITERAL:
|
||||||
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
|
generateLoadStoreOperands(instr, opcode, operandList, numOperands);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user