diff --git a/src/fileaccess.c b/src/fileaccess.c index 621de3c..c425ee7 100644 --- a/src/fileaccess.c +++ b/src/fileaccess.c @@ -37,7 +37,8 @@ int writeBinaryFile(word instrs[], char outputFile[]){ } -//reads assembly file of "inputFile" name, +//reads assembly file of "inputFile" name, and passes +//each line into a parser int readAssemblyFile(char inputFile[]) { if (!isValidFileFormat(filename, "s")){ exit(EXIT_FAILURE); @@ -53,7 +54,9 @@ int readAssemblyFile(char inputFile[]) { } while (fgets(savedLine, MAX_ASM_LINE_LENGTH-1, fp) != NULL) { - //pass line to parser + // removes newline char before saving them + savedLine[strcspn(savedLine, "\n")] = 0; + } exit(EXIT_SUCCESS); diff --git a/src/parser.c b/src/parser.c index 1572ef5..1c56c8e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,11 +1,19 @@ #include #include -#include +#include "parser.h" -#include +#include "a64instruction.h" //takes input string, read from asm file and returns //input as an a64 instruction + +//TODO: +// - use string matching to get opcode, and operands +// - check operand count +// - match opcode to a64 struct types +// - count operands and match type/values +// - generate final a64inst and return + a64inst_instruction parser(char asmLine[]){ - + } \ No newline at end of file