diff --git a/src/test/output.txt b/src/test/output.txt new file mode 100644 index 0000000..494d0b7 --- /dev/null +++ b/src/test/output.txt @@ -0,0 +1,55 @@ +Compiling... +Output... +.data +welcomeMessage:.asciiz"WelcometoaMIPSassemblyFibonacciSequencecalculator!\nThiswillcalculatethenthtermoftheFibonacciSequence.\n" +prompt:.asciiz"Enteranumber(ninputn>2)tofindthenthterm:" +foundTerm:.asciiz"Thenthtermis:" + +.text + +main: +li$v04 +la$a0welcomeMessage +syscall + +jalgetInput + +jalfibonacci +move$a0$v0 +li$v01 +syscall + +ori$v0$010 +syscall + +getInput: +li$v04 +la$a0prompt +syscall + +li$v05 +syscall +move$a0$v0 + +jr$ra + +fibonacci: +move$s1$a0 +li$t02 +li$t10 +li$t21 +li$t30 + +while: +bge$t0$s1done +add$t3$t1$t2 +move$t1$t2 + +move$t2$t3 +addi$t0$t01 + +bwhile + +done: +move$v0$t2 +jr$ra diff --git a/src/util/parse.h b/src/util/parse.h index f62932c..c105060 100644 --- a/src/util/parse.h +++ b/src/util/parse.h @@ -4,6 +4,8 @@ #include #include +#include "formats.h" + FILE * file; char * removeCommentsAndWhiteSpace(char * line) { @@ -27,13 +29,15 @@ char * removeCommentsAndWhiteSpace(char * line) { return newLine; } -char * parse(char * bareLine) { - char * function; - for(int i = 0; i < strlen(bareLine); i++) { +// Extract the R, I, or J format instruction from each "bare line". A bare line has no spaces or commas. +r* parse(char * bareLine) { + r* format = (r*)malloc(sizeof(r)); + for(int i = 0; i < strlen(bareLine); i++) { + if(bareLine[i] == '$') { + + } } - - return function; } int initParse(char * filepath) { @@ -49,9 +53,9 @@ int initParse(char * filepath) { return 0; } - // Get each line of the file. + // Get each line of the file, remove comments and whitespace, and attempt to parse while(fgets(lines, sizeof(lines), file)) - printf("%s\n", parse(removeCommentsAndWhiteSpace(lines))); + printf("%s\n", removeCommentsAndWhiteSpace(lines)); fclose(file);