successful removal of whitespace and comments, 1.0
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
[H[2J[3JCompiling...
|
||||
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
|
||||
+11
-7
@@ -4,6 +4,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user