Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -59,4 +59,4 @@ jobs:
echo building project
rm -f assembler
make
./assembler ps ps2 ps3 ps4 ps5 ps6 ps7
./assembler ps
Binary file modified assembler
Binary file not shown.
3 changes: 1 addition & 2 deletions assembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions input_output_results/multi_file_log.txt
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions input_output_results/no_files_received_log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Received 0 files, starting assembler process.

Finished processing - 0 file(s) that were received.
2 changes: 1 addition & 1 deletion tester/ps.am → input_output_results/ps.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tester/ps.as → input_output_results/ps.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ps2.as → input_output_results/ps2.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ clr r2
clr r3
m2
clr r3
MAIN:
LABB:
11 changes: 11 additions & 0 deletions input_output_results/ps2_log.txt
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions input_output_results/ps3_log.txt
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions input_output_results/ps4_log.txt
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions input_output_results/ps5_log.txt
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions input_output_results/ps6_log.txt
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions input_output_results/ps7_log.txt
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions input_output_results/ps_log.txt
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 7 additions & 3 deletions misc/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions passes/first_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ps.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions tester/ps2.as

This file was deleted.

15 changes: 0 additions & 15 deletions tester/ps3.as

This file was deleted.

8 changes: 0 additions & 8 deletions tester/ps4.as

This file was deleted.

7 changes: 0 additions & 7 deletions tester/ps5.as

This file was deleted.

7 changes: 0 additions & 7 deletions tester/ps7.as

This file was deleted.