#include #include #include "a64instruction/a64instruction.h" #include "parser.h" #include "fileio.h" #include "parser.h" #include "twopassassembly.c" int main(int argc, char **argv) { // Check the arguments if (argc < 3) { fprintf(stderr, "Error: A source file and an object output file are required. Syntax: ./assemble "); return EXIT_FAILURE; } // Load the source file into memory int lineCount = countLines(argv[1]); char **source = readAssemblyFile(argv[1], lineCount); // Parse the source file a64inst_instruction *instructions = parse(source, lineCount); // First Pass: Create the symbol table st *table = firstPass(instructions, lineCount); // Second Pass: Assemble the instructions word *binary = secondPass(instructions, lineCount, table); // 1000 is just a temp fix. // Write the binary to the output file writeBinaryFile(binary, argv[2], lineCount); // 1000 is just a temp fix. /* TODO: FREE MEMORY!! */ return EXIT_SUCCESS; }