comment code for understanding

This commit is contained in:
EDiasAlberto 2024-06-03 22:02:41 +01:00
parent 43dd6be707
commit ba1b614fc1
2 changed files with 16 additions and 5 deletions

View File

@ -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[]) { int readAssemblyFile(char inputFile[]) {
if (!isValidFileFormat(filename, "s")){ if (!isValidFileFormat(filename, "s")){
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -53,7 +54,9 @@ int readAssemblyFile(char inputFile[]) {
} }
while (fgets(savedLine, MAX_ASM_LINE_LENGTH-1, fp) != NULL) { 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); exit(EXIT_SUCCESS);

View File

@ -1,11 +1,19 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <parser.h> #include "parser.h"
#include <a64instruction.h> #include "a64instruction.h"
//takes input string, read from asm file and returns //takes input string, read from asm file and returns
//input as an a64 instruction //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[]){ a64inst_instruction parser(char asmLine[]){
} }