diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7ce2839..cd1f8f5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,16 +21,16 @@ jobs: echo building project rm -f assembler make - ./assembler ps ps2 ps3 ps4 ps5 ps6 ps7 - echo compare tester/ps.ob tester/main_tester - cmp tester/ps.ob tester/main_tester + ./assembler ps + echo compare ps.ob input_output_results/main_tester + diff ps.ob input_output_results/main_tester.ob -s - uses: actions/upload-artifact@v3 with: name: assembler.zip path: | misc passes - tester + input_output_results assembler assembler.c Makefile @@ -45,9 +45,9 @@ jobs: echo building project rm -f assembler make - ./assembler ps ps2 ps3 ps4 ps5 ps6 ps7 - echo compare tester/ps.ob tester/main_tester - cmp tester/ps.ob tester/main_tester + ./assembler ps + echo compare ps.ob input_output_results/main_tester + diff ps.ob input_output_results/main_tester.ob -s build_and_test_macos-latest: runs-on: macos-latest @@ -59,4 +59,4 @@ jobs: echo building project rm -f assembler make - ./assembler ps ps2 ps3 ps4 ps5 ps6 ps7 \ No newline at end of file + ./assembler ps diff --git a/assembler b/assembler index fa4bb40..d8ab237 100755 Binary files a/assembler and b/assembler differ diff --git a/assembler.c b/assembler.c index 670e055..e6515c9 100644 --- a/assembler.c +++ b/assembler.c @@ -41,10 +41,9 @@ void mainRunner(int argc, char **argv) { lineNum = 1; firstPass(line, outP, &errors, outPutFileName); } else { - fclose(outP); fclose(inp); remove(outPutFileName); - printError("due to errors not continuing with flow on current file, continue with next file..."); + printError("due to errors not continuing with flow on current file, continue with next file"); } printf("===>>>>>> Finished file: %s <<<<<<===\n", outPutFileName); printf("======================================================================\n\n"); diff --git a/tester/main_tester b/input_output_results/main_tester.ob similarity index 100% rename from tester/main_tester rename to input_output_results/main_tester.ob diff --git a/input_output_results/multi_file_log.txt b/input_output_results/multi_file_log.txt new file mode 100644 index 0000000..c299a25 --- /dev/null +++ b/input_output_results/multi_file_log.txt @@ -0,0 +1,62 @@ +Received 3 files, starting assembler process. + +Processing: ps7.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Too many commas in 1 line +1 --->Too many commas in 1 line +1 --->Too many commas in 1 line +2 --->Wrong number of operands for command: clr +3 --->Error: CMD: [ ... ] not found. +4 --->Error: CMD: [ #$%#@$%@#$#@ ] not found. +5 --->Error: CMD: [ r1 ] not found. +6 --->Undefined label: MAIN: +7 --->Wrong number of operands for command: jsr +8 --->expected regs between 10 and 15 +9 --->reg: r32, wrong number +===>>>>>> First pass finished: Errors: 11 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps7.am <<<<<<=== +====================================================================== + +Processing: ps4.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Error: CMD: [ mow ] not found. +2 --->Error: CMD: [ wom ] not found. +3 --->Error: CMD: [ step ] not found. +4 --->Error: CMD: [ jpr ] not found. +5 --->Error: CMD: [ ABC ] not found. +7 --->Operand: 1, did not find matching sort type + +9 --->String not declared properly +===>>>>>> First pass finished: Errors: 7 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps4.am <<<<<<=== +====================================================================== + +Processing: ps3.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Undefined label: LIST: +2 --->Wrong number of operands for command: lea +3 --->Wrong number of operands for command: mov +5 --->Too many commas in 1 line +6 --->Wrong number of operands for command: mov +7 --->Undefined label: MAIN: +8 --->Wrong number of operands for command: mov +8 --->Too many commas in 1 line +9 --->Wrong number of operands for command: clr +10 --->Wrong number of operands for command: dec +11 --->Wrong number of operands for command: bne +12 --->Wrong number of operands for command: lea +13 --->No data after .data declaration +14 --->Undefined label: LABEL: + +14 --->No characters after .string declaration or string undeclared properly +===>>>>>> First pass finished: Errors: 15 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps3.am <<<<<<=== +====================================================================== + +Finished processing - 3 file(s) that were received. diff --git a/input_output_results/no_files_received_log.txt b/input_output_results/no_files_received_log.txt new file mode 100644 index 0000000..ed67a73 --- /dev/null +++ b/input_output_results/no_files_received_log.txt @@ -0,0 +1,3 @@ +Received 0 files, starting assembler process. + +Finished processing - 0 file(s) that were received. diff --git a/tester/ps.am b/input_output_results/ps.am similarity index 90% rename from tester/ps.am rename to input_output_results/ps.am index 9531cf2..3c96bfa 100644 --- a/tester/ps.am +++ b/input_output_results/ps.am @@ -13,7 +13,7 @@ dec K .entry MAIN sub LOOP[r10] ,r14 END: stop -STR: .string “abcd” +STR: .string "abcd" LIST: .data 6, -9 .data -100 .entry K diff --git a/tester/ps.as b/input_output_results/ps.as similarity index 92% rename from tester/ps.as rename to input_output_results/ps.as index 4d5ba64..17a51da 100644 --- a/tester/ps.as +++ b/input_output_results/ps.as @@ -17,7 +17,7 @@ dec K .entry MAIN sub LOOP[r10] ,r14 END: stop -STR: .string “abcd” +STR: .string "abcd" LIST: .data 6, -9 .data -100 .entry K diff --git a/tester/ps.ent b/input_output_results/ps.ent similarity index 100% rename from tester/ps.ent rename to input_output_results/ps.ent diff --git a/tester/ps.ext b/input_output_results/ps.ext similarity index 100% rename from tester/ps.ext rename to input_output_results/ps.ext diff --git a/tester/ps.ob b/input_output_results/ps.ob similarity index 100% rename from tester/ps.ob rename to input_output_results/ps.ob diff --git a/ps2.as b/input_output_results/ps2.as similarity index 94% rename from ps2.as rename to input_output_results/ps2.as index 15aa2b2..27424a2 100644 --- a/ps2.as +++ b/input_output_results/ps2.as @@ -8,4 +8,4 @@ clr r2 clr r3 m2 clr r3 -MAIN: \ No newline at end of file +LABB: \ No newline at end of file diff --git a/input_output_results/ps2_log.txt b/input_output_results/ps2_log.txt new file mode 100644 index 0000000..d5f6ba7 --- /dev/null +++ b/input_output_results/ps2_log.txt @@ -0,0 +1,11 @@ +Received 1 files, starting assembler process. + +Processing: ps2.as +--->macro doesnt have a closure with 'endm' (end of code) will not create am file and continue with process. +===>>>>>> Pre assembler finished: Errors: 1 + +-->due to errors not continuing with flow on current file, continue with next file +===>>>>>> Finished file: tester/ps2.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/tester/ps3.am b/input_output_results/ps3.am similarity index 100% rename from tester/ps3.am rename to input_output_results/ps3.am diff --git a/ps3.as b/input_output_results/ps3.as similarity index 100% rename from ps3.as rename to input_output_results/ps3.as diff --git a/input_output_results/ps3_log.txt b/input_output_results/ps3_log.txt new file mode 100644 index 0000000..29ba56a --- /dev/null +++ b/input_output_results/ps3_log.txt @@ -0,0 +1,27 @@ +Received 1 files, starting assembler process. + +Processing: ps3.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Undefined label: LIST: +2 --->Wrong number of operands for command: lea +3 --->Wrong number of operands for command: mov +5 --->Too many commas in 1 line +6 --->Wrong number of operands for command: mov +7 --->Undefined label: MAIN: +8 --->Wrong number of operands for command: mov +8 --->Too many commas in 1 line +9 --->Wrong number of operands for command: clr +10 --->Wrong number of operands for command: dec +11 --->Wrong number of operands for command: bne +12 --->Wrong number of operands for command: lea +13 --->No data after .data declaration +14 --->Undefined label: LABEL: + +14 --->No characters after .string declaration or string undeclared properly +===>>>>>> First pass finished: Errors: 15 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps3.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/tester/ps4.am b/input_output_results/ps4.am similarity index 100% rename from tester/ps4.am rename to input_output_results/ps4.am diff --git a/ps4.as b/input_output_results/ps4.as similarity index 100% rename from ps4.as rename to input_output_results/ps4.as diff --git a/input_output_results/ps4_log.txt b/input_output_results/ps4_log.txt new file mode 100644 index 0000000..3023918 --- /dev/null +++ b/input_output_results/ps4_log.txt @@ -0,0 +1,19 @@ +Received 1 files, starting assembler process. + +Processing: ps4.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Error: CMD: [ mow ] not found. +2 --->Error: CMD: [ wom ] not found. +3 --->Error: CMD: [ step ] not found. +4 --->Error: CMD: [ jpr ] not found. +5 --->Error: CMD: [ ABC ] not found. +7 --->Operand: 1, did not find matching sort type + +9 --->String not declared properly +===>>>>>> First pass finished: Errors: 7 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps4.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/tester/ps5.am b/input_output_results/ps5.am similarity index 100% rename from tester/ps5.am rename to input_output_results/ps5.am diff --git a/ps5.as b/input_output_results/ps5.as similarity index 100% rename from ps5.as rename to input_output_results/ps5.as diff --git a/input_output_results/ps5_log.txt b/input_output_results/ps5_log.txt new file mode 100644 index 0000000..6625a0d --- /dev/null +++ b/input_output_results/ps5_log.txt @@ -0,0 +1,14 @@ +Received 1 files, starting assembler process. + +Processing: ps5.as +===>>>>>> Pre assembler finished: Errors: 0 +===>>>>>> First pass finished: Errors: 0 +--->Usage of undeclared label found: LIST, error +--->Usage of undeclared label found: NEWLABEL, error +===>>>>>> Second pass finished: Errors: 2 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps5.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/input_output_results/ps6_log.txt b/input_output_results/ps6_log.txt new file mode 100644 index 0000000..630b275 --- /dev/null +++ b/input_output_results/ps6_log.txt @@ -0,0 +1,7 @@ +Received 1 files, starting assembler process. + +Processing: ps6.as +============================================================ + +-->file not found, skipping to next +Finished processing - 1 file(s) that were received. diff --git a/tester/ps7.am b/input_output_results/ps7.am similarity index 100% rename from tester/ps7.am rename to input_output_results/ps7.am diff --git a/ps7.as b/input_output_results/ps7.as similarity index 100% rename from ps7.as rename to input_output_results/ps7.as diff --git a/input_output_results/ps7_log.txt b/input_output_results/ps7_log.txt new file mode 100644 index 0000000..f4cb0da --- /dev/null +++ b/input_output_results/ps7_log.txt @@ -0,0 +1,22 @@ +Received 1 files, starting assembler process. + +Processing: ps7.as +===>>>>>> Pre assembler finished: Errors: 0 +1 --->Too many commas in 1 line +1 --->Too many commas in 1 line +1 --->Too many commas in 1 line +2 --->Wrong number of operands for command: clr +3 --->Error: CMD: [ ... ] not found. +4 --->Error: CMD: [ #$%#@$%@#$#@ ] not found. +5 --->Error: CMD: [ r1 ] not found. +6 --->Undefined label: MAIN: +7 --->Wrong number of operands for command: jsr +8 --->expected regs between 10 and 15 +9 --->reg: r32, wrong number +===>>>>>> First pass finished: Errors: 11 + +-->due to errors not continuing with flow on current file, continue with next file... +===>>>>>> Finished file: tester/ps7.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/input_output_results/ps_log.txt b/input_output_results/ps_log.txt new file mode 100644 index 0000000..6476061 --- /dev/null +++ b/input_output_results/ps_log.txt @@ -0,0 +1,10 @@ +Received 1 files, starting assembler process. + +Processing: ps.as +===>>>>>> Pre assembler finished: Errors: 0 +===>>>>>> First pass finished: Errors: 0 +===>>>>>> Second pass finished: Errors: 0 +===>>>>>> Finished file: tester/ps.am <<<<<<=== +====================================================================== + +Finished processing - 1 file(s) that were received. diff --git a/misc/utils.c b/misc/utils.c index 2e3793d..9acd5ff 100644 --- a/misc/utils.c +++ b/misc/utils.c @@ -100,7 +100,7 @@ FILE *inputFileInit(char **argv, FILE *inp, int *inputFileCounter) { * @return */ FILE *outputFileInit(FILE *outP, char *outPutFileName, char *inputName) { - sprintf(outPutFileName, "tester/%s.am", inputName); + sprintf(outPutFileName, "%s.am", inputName); outP = fopen(outPutFileName, "w+"); return outP; } @@ -573,7 +573,7 @@ void errorHandler(int *errors, char *currLine) { i = 0; isComma = FALSE; while (lineForErrorHandling[i] != '\0') { - if (lineForErrorHandling[i] == '"' && isComma == FALSE) { + if (isComma == FALSE && lineForErrorHandling[i] == '"') { isComma = TRUE; i++; continue; @@ -583,7 +583,11 @@ void errorHandler(int *errors, char *currLine) { } i++; } - printf("%d --->String not declared properly\n", lineNum); + printf("\n"); + if (isComma == TRUE){ + *errors += 1; + printf("%d --->String not declared properly\n", lineNum); + } } } diff --git a/passes/first_pass.c b/passes/first_pass.c index 808e893..177d3e8 100644 --- a/passes/first_pass.c +++ b/passes/first_pass.c @@ -41,10 +41,10 @@ int codeDataOrString(char *line, machineCode *mCode, long *DC, bool withLabel, c stringCopy(mCode[*DC].declaredLabel, tempLine); stringCopy(tempLine, line); } - strtok(tempLine, "”"); + strtok(tempLine, "\""); tempLine = strtok(NULL, ""); if (tempLine == NULL) { - printf("%d --->No characters after .string declaration or string undeclared properly\n", lineNum-1); + printf("%d --->No characters after .string declaration or string undeclared properly\n", lineNum); *errors += 1; return 0; } diff --git a/ps.as b/ps.as index 4d5ba64..17a51da 100644 --- a/ps.as +++ b/ps.as @@ -17,7 +17,7 @@ dec K .entry MAIN sub LOOP[r10] ,r14 END: stop -STR: .string “abcd” +STR: .string "abcd" LIST: .data 6, -9 .data -100 .entry K diff --git a/tester/ps2.as b/tester/ps2.as deleted file mode 100644 index 15aa2b2..0000000 --- a/tester/ps2.as +++ /dev/null @@ -1,11 +0,0 @@ -mov r1, r3 -MAIN: clr r3 -macro m2 -dec r4 -mov #1, r2 -clr r1 -clr r2 -clr r3 -m2 -clr r3 -MAIN: \ No newline at end of file diff --git a/tester/ps3.as b/tester/ps3.as deleted file mode 100644 index 50fe254..0000000 --- a/tester/ps3.as +++ /dev/null @@ -1,15 +0,0 @@ -LIST: -lea -mov r1 -clr r2 -mov #23, r14 -mov r1, r2, r3 -MAIN: -mov 1 -clr r4, r5, r7 -dec 5 rpfgihjerwfwoei0fhwefewi0uofhw9uweuf9oe -bne -lea -.data -LABEL: -.string \ No newline at end of file diff --git a/tester/ps4.as b/tester/ps4.as deleted file mode 100644 index 9613570..0000000 --- a/tester/ps4.as +++ /dev/null @@ -1,8 +0,0 @@ -mow r1, r2 -wom r3, r6 -step -jpr A -ABC DCA -mov #1, R23 -clr 1 -clr REG \ No newline at end of file diff --git a/tester/ps5.as b/tester/ps5.as deleted file mode 100644 index c4b66da..0000000 --- a/tester/ps5.as +++ /dev/null @@ -1,7 +0,0 @@ -.extern W - .entry LIST -MAIN: add r3, LIST -clr r2 -clr r3 -clr r4 -bne NEWLABEL \ No newline at end of file diff --git a/tester/ps7.as b/tester/ps7.as deleted file mode 100644 index 6a61e9e..0000000 --- a/tester/ps7.as +++ /dev/null @@ -1,7 +0,0 @@ -mov r1,,,r3 -clr A, , -... -#$%#@$%@#$#@ -r1 r2 -MAIN: -jsr \ No newline at end of file