classify branch type from opcode
This commit is contained in:
parent
bb3218b535
commit
13e2cc8c9d
16
src/parser.c
16
src/parser.c
@ -10,13 +10,23 @@
|
||||
//TODO:
|
||||
// - use string matching to get opcode, and operands (DONE)
|
||||
// - check operand count (DONE)
|
||||
// - match opcode to a64 struct types
|
||||
// - match opcode to a64 struct types (PARTIALLY DONE)
|
||||
// - count operands and match type/values
|
||||
// - generate final a64inst and return
|
||||
|
||||
void classifyOpcode(char* opcode, a64inst_instruction *instr){
|
||||
if(strcmp(opcode, "b") == 0 || strcmp(opcode, "br") == 0 || strncmp(opcode, "b.", strlen("b.")) == 2){
|
||||
instr->type = a64inst_BRANCH;
|
||||
if((int isUnconditional = strcmp(opcode, "b")) == 0 ||
|
||||
(int isRegister = strcmp(opcode, "br")) == 0 ||
|
||||
strncmp(opcode, "b.", 2) == 0){
|
||||
instr->type = a64inst_BRANCH;
|
||||
if(isUnconditional){
|
||||
instr->data.BranchData.BranchType = a64inst_UNCONDITIONAL;
|
||||
} else if (isRegister){
|
||||
instr->data.BranchData.BranchType = a64inst_REGISTER;
|
||||
} else {
|
||||
instr->data.BranchData.BranchType = a64inst_CONDITIONAL;
|
||||
//instr->data.branchData.processOpData.cond = {remove first two chars of opcode}
|
||||
}
|
||||
} else if(strcmp(opcode, "ldr") == 0 || strcmp(opcode, "str") == 0){
|
||||
//loading/storing instruction; classify operands
|
||||
instr->type = a64inst_SINGLETRANSFER;
|
||||
|
||||
@ -11,7 +11,7 @@ void generateSymbolTable(a64inst_instruction instrs[], int numInstrs){
|
||||
}
|
||||
}
|
||||
|
||||
word assembleBranch(a64inst_instruction *instr){
|
||||
word assembleBranch(a64inst_instruction *instr, int ){
|
||||
word binInstr = 0;
|
||||
switch (instr->data.BranchData.BranchType)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user