53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
//generates assembled code based on two pass assembly method
|
|
|
|
void generateSymbolTable(a64inst_instruction instrs[], int numInstrs){
|
|
//TODO:
|
|
//generate symbol table based on inputted assembly code and labels
|
|
for(int i=0; i<numInstrs; i++){
|
|
// discuss defining a LABEL type
|
|
if(instrs[i]->type==LABEL){
|
|
// symbol table stuff here
|
|
}
|
|
}
|
|
}
|
|
|
|
word assembleBranch(a64inst_instruction *instr, int ){
|
|
word binInstr = 0;
|
|
switch (instr->data.BranchData.BranchType)
|
|
{
|
|
case a64inst_UNCONDITIONAL:
|
|
//000101
|
|
//25-0: sign extended simm26
|
|
|
|
break;
|
|
case a64inst_REGISTER:
|
|
//1101011
|
|
//0000
|
|
//11111
|
|
//000000
|
|
//9-5: address from register
|
|
//0000
|
|
|
|
break;
|
|
case a64inst_CONDITIONAL:
|
|
// 01010100
|
|
// 25-5: sign extended offset
|
|
// 4-0: 0{condition}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void firstPass(a64inst_instruction instrs[], int numInstrs){
|
|
//TODO:
|
|
// -iterate over instructions, adding to symbol table
|
|
// create symbol table and map labels to addresses/lines
|
|
}
|
|
|
|
void secondPass(a64inst_instruction instrs[], int numInstrs){
|
|
//TODO:
|
|
// iterate over instructions again, this time replacing labels
|
|
// with values from symbol table
|
|
// after a line has had all the values replaced, assemble it and append
|
|
} |