diff options
Diffstat (limited to 'assembler.c')
-rw-r--r-- | assembler.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/assembler.c b/assembler.c index 9ffdb85..7ae699d 100644 --- a/assembler.c +++ b/assembler.c @@ -7,6 +7,9 @@ #include "instruction.h" #include "output/output_bin.h" +//#define DEBUG +#include "debug.h" + void print_help(const char *argv0) { fprintf(stderr, "Syntax: %s <in.asm> <out.bin>\n", argv0); @@ -45,12 +48,14 @@ int main(int argc, char **argv) perror("fopen"); return error_ret; } + debug("Opened fin\n"); if ((fout = fopen(path_out, "wb")) == NULL) { fprintf(stderr, "Error opening %s: ", path_out); perror("fopen"); return error_ret; } + debug("Opened fout\n"); /****/ struct token *tokens = NULL; size_t tok_count = 0; @@ -58,6 +63,8 @@ int main(int argc, char **argv) if ((tokens = lex(path_in, fin, &tok_count)) == NULL) return error_ret; + debug("Lexed.\n"); + /* FIXME package these things into `tok_result`, `parse_result` etc */ struct instruction *insts; size_t insts_count; @@ -66,6 +73,8 @@ int main(int argc, char **argv) if ((ret = parse(path_in, fin, &labels, &labels_count, tokens, tok_count, &insts, &insts_count))) return error_ret && ret; + debug("Parsed.\n"); + /* FIXME insert pass for sanity checking identifiers, sizes of values */ /* FIXME insert optional pass for optimisation */ @@ -73,5 +82,7 @@ int main(int argc, char **argv) if ((ret = output_bin(fout, labels, labels_count, insts, insts_count))) return error_ret && ret; + debug("Output.\n"); + return 0; } |