classify register type and base register for load/store
This commit is contained in:
parent
1011d7be71
commit
872d4224f8
14
src/parser.c
14
src/parser.c
@ -14,6 +14,7 @@
|
|||||||
// - count operands and match type/values
|
// - count operands and match type/values
|
||||||
// - generate final a64inst and return
|
// - generate final a64inst and return
|
||||||
|
|
||||||
|
//calculate offsets from string
|
||||||
void calcluateAddressFormat(a64inst_instruction *instr, char *operandList[]){
|
void calcluateAddressFormat(a64inst_instruction *instr, char *operandList[]){
|
||||||
if(strcmp(operandList[0][strlen(operandList[0])-1], "{") == 0) {
|
if(strcmp(operandList[0][strlen(operandList[0])-1], "{") == 0) {
|
||||||
//unsigned immediate offset
|
//unsigned immediate offset
|
||||||
@ -36,6 +37,14 @@ void calcluateAddressFormat(a64inst_instruction *instr, char *operandList[]){
|
|||||||
void generateLoadStoreOperands(a64inst_instruction *instr, char *opcode, char *operandList[]){
|
void generateLoadStoreOperands(a64inst_instruction *instr, char *opcode, char *operandList[]){
|
||||||
switch(instr->data.type){
|
switch(instr->data.type){
|
||||||
case a64inst_SINGLETRANSFER:
|
case a64inst_SINGLETRANSFER:
|
||||||
|
if(strcmp(operandList[0][0], "x")==0){
|
||||||
|
//x-register
|
||||||
|
instr->data.regType = 1;
|
||||||
|
} else {
|
||||||
|
instr->data.regType = 0;
|
||||||
|
}
|
||||||
|
char *endptr;
|
||||||
|
instr->processOpData.base = strtol(operandList[0][0]+1, endptr, 2);
|
||||||
calcluateAddressFormat(instr, operandList);
|
calcluateAddressFormat(instr, operandList);
|
||||||
break;
|
break;
|
||||||
case a64inst_LOADLITERAL:
|
case a64inst_LOADLITERAL:
|
||||||
@ -97,10 +106,11 @@ void classifyOpcode(char* opcode, a64inst_instruction *instr, char *operandList[
|
|||||||
if( *address == '['){
|
if( *address == '['){
|
||||||
//type is register
|
//type is register
|
||||||
instr->type = a64inst_SINGLETRANSFER;
|
instr->type = a64inst_SINGLETRANSFER;
|
||||||
|
instr->data.SingleTransferOpType = a64inst_SINGLE_TRANSFER_SINGLE_DATA_TRANSFER;
|
||||||
if(isLoad == 0){
|
if(isLoad == 0){
|
||||||
instr->data.processOpData.singleDataTransferData.transferType = a64inst_LOAD;
|
instr->data.processOpData.transferType = a64inst_LOAD;
|
||||||
} else {
|
} else {
|
||||||
instr->data.processOpData.singleDataTransferData.transferType = a64inst_STORE;
|
instr->data.processOpData.transferType = a64inst_STORE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
instr->type = a64inst_LOADLITERAL;
|
instr->type = a64inst_LOADLITERAL;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user