assemble branch instructions
This commit is contained in:
parent
262fd6219d
commit
6177b2f748
@ -10,7 +10,7 @@
|
||||
//TODO:
|
||||
// - use string matching to get opcode, and operands (DONE)
|
||||
// - check operand count (DONE)
|
||||
// - match opcode to a64 struct types (PARTIALLY DONE)
|
||||
// - match opcode to a64 struct types (DONE)
|
||||
// - count operands and match type/values
|
||||
// - generate final a64inst and return
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
#include "global.h"
|
||||
|
||||
//generates assembled code based on two pass assembly method
|
||||
|
||||
void generateSymbolTable(a64inst_instruction instrs[], int numInstrs){
|
||||
@ -13,26 +15,28 @@ void generateSymbolTable(a64inst_instruction instrs[], int numInstrs){
|
||||
|
||||
word assembleBranch(a64inst_instruction *instr, int ){
|
||||
word binInstr = 0;
|
||||
binInstr += (5^28); //101 start of branch instr
|
||||
switch (instr->data.BranchData.BranchType)
|
||||
{
|
||||
case a64inst_UNCONDITIONAL:
|
||||
//000101
|
||||
//25-0: sign extended simm26
|
||||
|
||||
binInstr += instr->data.processOpData.unconditionalOffset;
|
||||
break;
|
||||
case a64inst_REGISTER:
|
||||
//1101011
|
||||
//0000
|
||||
//10000
|
||||
//11111
|
||||
//000000
|
||||
//9-5: address from register
|
||||
//0000
|
||||
|
||||
binInstr += ((instr->processOpData.src)^5);
|
||||
break;
|
||||
case a64inst_CONDITIONAL:
|
||||
// 01010100
|
||||
// 25-5: sign extended offset
|
||||
// 4-0: 0{condition}
|
||||
binInstr += ((instr->processOpData.offset)^5);
|
||||
binInstr += instr->processOpData.cond;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user