parse branch labels and modify load literal struct
This commit is contained in:
parent
5bb68d95e1
commit
004ba24b5a
@ -34,6 +34,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
char* label;
|
||||||
} a64inst_LoadLiteralData;
|
} a64inst_LoadLiteralData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@ -25,10 +25,13 @@ void setBits(word* wrd, uint8_t lsb, uint8_t msb, word value) {
|
|||||||
*wrd |= (value << lsb) & mask;
|
*wrd |= (value << lsb) & mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static int getLabelOffset(symbol_table* table, char* label, int currentIndex) {
|
static int getLabelOffset(symbol_table* table, char* label, int currentIndex) {
|
||||||
address target = st_get(table, label);
|
address target = st_get(table, label);
|
||||||
return target - (currentIndex * 4);
|
return target - (currentIndex * 4);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Generates assembled code based on the two-pass assembly method
|
// Generates assembled code based on the two-pass assembly method
|
||||||
word encodeBranch(a64inst_instruction *instr) {
|
word encodeBranch(a64inst_instruction *instr) {
|
||||||
|
|||||||
@ -322,6 +322,7 @@ void parseBranch(a64inst_instruction *instr, char* opcode, char *operandList[])
|
|||||||
//define and sign extend immediate offset
|
//define and sign extend immediate offset
|
||||||
//use symbol table
|
//use symbol table
|
||||||
printf("unconditional");
|
printf("unconditional");
|
||||||
|
instr->data.BranchData.processOpData.unconditionalData.label = operandList[1];
|
||||||
break;
|
break;
|
||||||
case a64inst_REGISTER:
|
case a64inst_REGISTER:
|
||||||
instr->data.BranchData.processOpData.registerData.src = getOperandNumber(operandList[1]);
|
instr->data.BranchData.processOpData.registerData.src = getOperandNumber(operandList[1]);
|
||||||
@ -345,8 +346,10 @@ void parseBranch(a64inst_instruction *instr, char* opcode, char *operandList[])
|
|||||||
} else if (strcmp(condition, "al")==0){
|
} else if (strcmp(condition, "al")==0){
|
||||||
instr->data.BranchData.processOpData.conditionalData.cond = AL;
|
instr->data.BranchData.processOpData.conditionalData.cond = AL;
|
||||||
}
|
}
|
||||||
|
instr->data.BranchData.processOpData.unconditionalData.label = operandList[1];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
//calculate offset from symbol table.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user