diff --git a/src/parser.c b/src/parser.c index 1c30fc3..4961480 100644 --- a/src/parser.c +++ b/src/parser.c @@ -14,6 +14,17 @@ // - 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; + } else if(strcmp(opcode, "ldr") == 0 || strcmp(opcode, "str") == 0){ + //loading/storing instruction; classify operands + instr->type = a64inst_SINGLETRANSFER; + } else { + //data processing + } +} + char *tokeniseOperands(char* str, int operandCount, char *operands[]){ char *operandsDupe = strdup(str); int operandCount = 0; @@ -43,8 +54,10 @@ a64inst_instruction *parser(char asmLine[]){ if(opcode[0]=="."){ //type is directive + //define new type in a64instr struct } else if(opcode[strlen(opcode)-1]==":") { //type is label + //use symbol table to assemble } else { //type is instruction int operandCount = 0; diff --git a/src/twopassassembly.c b/src/twopassassembly.c new file mode 100644 index 0000000..24080f3 --- /dev/null +++ b/src/twopassassembly.c @@ -0,0 +1,12 @@ +//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; itype==LABEL){ + // symbol table stuff here + } + } +}