Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
BassamMattar committed Jun 11, 2018
1 parent 8aaf65d commit f3df144
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 151 deletions.
74 changes: 37 additions & 37 deletions ObjectCode.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
HLAB2C 001000fff45e
T0010000b03000069000a0500009003
T0003e8030fa049
T0003eb03050001
T0003ee030fa043
T0003f103032056
T0003f403032054
T0003f703032052
T0003fa0303204f
T0003fd0303204f
T0004000303204f
T0004030303204f
T00040603032049
T0004090303204c
T00040c0303204c
T00040f041d10000c
T00041303050000
T00041603532021
T000419030f2022
T00041c0353a020
T00041f032b201c
T00042203332009
T0004250357a01d
T000428032d0005
T00042b033b2fee
T00042e033f2014
T00043103000002
T00043a046145fd56
T00043f06537472696e67
T00044a00
T00044b00
T00044c00
T00044f03000610
T00045203ffff68
T00045500
T00045803000658
T00045b03000fff
HLAB2C 001000fff45e
T0010000b03000069000a0500009003
T0003e8030fa049
T0003eb03050001
T0003ee030fa043
T0003f103032056
T0003f403032054
T0003f703032052
T0003fa0303204f
T0003fd0303204f
T0004000303204f
T0004030303204f
T00040603032049
T0004090303204c
T00040c0303204c
T00040f041d10000c
T00041303050000
T00041603532021
T000419030f2022
T00041c0353a020
T00041f032b201c
T00042203332009
T0004250357a01d
T000428032d0005
T00042b033b2fee
T00042e033f2014
T00043103000002
T00043a046145fd56
T00043f06537472696e67
T00044a015f
T00044b01df
T00044c03386a35
T00044f03000610
T00045203ffff68
T0004550300007c
T00045803000658
T00045b03000fff
E001000
3 changes: 1 addition & 2 deletions src/IntermediateFileParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ vector<IntermediateFileParser::entry> IntermediateFileParser::getEntriesVector()
ifstream intermediatefile(path);
getline(intermediatefile, line);
getline(intermediatefile, line);

if (intermediatefile.is_open()) {
while (getline(intermediatefile, line)) {
trim(&line);
entry e = getSuitableEntry(line);
//debugEntry(e);
debugEntry(e);
if(validEntry(e)) {
entryVector.push_back(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ObjectProgramGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void ObjectProgramGenerator::generate_program_code(vector<IntermediateFileParser
output.append(generate_text_records(entries));
output.append(generate_modification_records(entries));
output.append(generate_end_record(entries));
write_string_to_file(output,"/home/sajed/CLionProjects/untitled/ObjectCode.txt");
write_string_to_file(output,"ObjectCode.txt");
}

string ObjectProgramGenerator::generate_text_records(vector<IntermediateFileParser::entry> entries) const {
Expand Down
6 changes: 4 additions & 2 deletions src/Pass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ void Pass2::debugUtilities() {
int Pass2::excute(string outPath) {

IntermediateFileParser intermediateParser = *new IntermediateFileParser(outPath);
cout << ".size()" << endl;
vector<IntermediateFileParser::entry> allEntryVector = intermediateParser.getEntriesVector();
cout << allEntryVector.size() << endl;
LabelProcessor labelProcessor = *new LabelProcessor();
unordered_map<string,string> labelAddresses = labelProcessor.assignLabelAddresses(&allEntryVector);
if(labelProcessor.getErrorFlag()) {
Expand All @@ -153,9 +155,9 @@ int Pass2::excute(string outPath) {
//debugLabelAddresses(labelAddresses);
//debugEntriesVectors(allEntryVector);
//debugAddressMode(allEntryVector);
/*

ObjectProgramGenerator objGen = *new ObjectProgramGenerator();
objGen.generate_program_code(allEntryVector);*/
objGen.generate_program_code(allEntryVector);
return 1;
}

Expand Down
12 changes: 6 additions & 6 deletions src/assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ using namespace std;
int main(int argc, const char * argv[]) {

//Pass I
string path = "/home/sajed/CLionProjects/untitled/test.txt";
/*string path = "test2.txt";
Pass1 pass1(path);
cout << endl << "An intermediate file was written to the path: " << pass1.outPath << endl;
if(!pass1.error) {
if(!pass1.error) {*/
//Pass II
Pass2 pass2;
int successful = pass2.excute(pass1.outPath);
int successful = pass2.excute("testOut.txt");
if (!successful) {
cout << "Pass2 assembled unsuccessfully";
}
} else {
/* } else {
cout << "Pass1 assembled unsuccessfully" << " : # of errors = " << pass1.getNumOfErrors();
}
}
}*/
}
98 changes: 49 additions & 49 deletions test2Out.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
Line no. Address Label Mnemonic Operands Comments
Op-code
1 000000 .23456789
2 000000 .sajed
3 000000 .23456789
4 001000 LAB2C START 1000
5 001000 LDA ALPHA
6 001003 LDB #10
7 001006 LDX #0
8 001009 ADDR A,B
9 00100b STA SAVEW,X
10 00100e LDX #1
11 00100e .format 4
12 001011 STA SAVEW,X
13 001014 LDA =X'5F'
14 001017 LDA =X'DF'
15 00101a LDA =C'8JF'
16 00101d LDA =W'1524'
17 00101d .sajed
18 001020 LDA =W'1524'
19 001023 LDA =W'1624'
20 001026 LDA =W'4095'
21 001026 .format 4
22 001029 +SUB #12
23 00102d LDX #0
24 001030 LDCH HEXCHAR
25 001033 STA INPUT
26 001036 LOOP LDCH STRING,X
27 001039 COMP INPUT
28 00103c JEQ FOUND
29 00103f STCH OUTPUT,X
30 001042 TIX #5
31 001045 JLT LOOP
32 001048 FOUND J OUT
33 001048 .format 4
34 00104b ALPHA WORD 2
35 00104e SAVEW RESW 2
36 001054 HEXACHAR BYTE X'61'
37 001056 INPUT RESB 1
38 001057 STRING BYTE 'STRING'
39 00105c OUTPUT RESB 5
40 001061 =x'5f' BYTE x'5f'
40 001062 =x'df' BYTE x'df'
40 001063 =c'8jf' BYTE c'8jf'
40 001066 =w'1524' WORD 1524
40 001069 =w'1524' WORD 1524
40 00106c =w'1624' WORD 1624
40 00106f =w'4095' WORD 4095
40 001072 END
Line no. Address Label Mnemonic Operands Comments
Op-code
1 000000 .23456789
2 000000 .sajed
3 000000 .23456789
4 001000 LAB2C START 1000
5 001000 LDA ALPHA
6 001003 LDB #10
7 001006 LDX #0
8 001009 ADDR A,B
9 00100b STA SAVEW,X
10 00100e LDX #1
11 00100e .format 4
12 001011 STA SAVEW,X
13 001014 LDA =X'5f'
14 001017 LDA =X'df'
15 00101a LDA =C'8jf'
16 00101d LDA =W'1524'
17 00101d .sajed
18 001020 LDA =W'1524'
19 001023 LDA =W'1624'
20 001026 LDA =W'4095'
21 001026 .format 4
22 001029 +SUB #12
23 00102d LDX #0
24 001030 LDCH HEXCHAR
25 001033 STA INPUT
26 001036 LOOP LDCH STRING,X
27 001039 COMP INPUT
28 00103c JEQ FOUND
29 00103f STCH OUTPUT,X
30 001042 TIX #5
31 001045 JLT LOOP
32 001048 FOUND J OUT
33 001048 .format 4
34 00104b ALPHA WORD 2
35 00104e SAVEW RESW 2
36 001054 HEXACHAR BYTE X'61'
37 001055 INPUT RESB 1
***Operand format is not compatible with operation***
38 001057 STRING BYTE 'STRING'
39 001056 OUTPUT RESB 5
40 00105b =X'5f' BYTE X'5f'
40 00105c =X'df' BYTE X'df'
40 00105d =C'8jf' BYTE C'8jf'
40 001060 =W'1524' WORD 1524
40 001063 =W'1624' WORD 1624
40 001066 =W'4095' WORD 4095
40 001069 END
22 changes: 11 additions & 11 deletions test2SymTable.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

SymTable Address

INPUT 1056
HEXACHAR 1054
LOOP 1036
OUTPUT 105c
STRING 1057
FOUND 1048
SAVEW 104e
ALPHA 104b
SymTable Address
OUTPUT 1056
STRING 1056
FOUND 1048
SAVEW 104e
LOOP 1036
ALPHA 104b
HEXACHAR 1054
INPUT 1055
84 changes: 41 additions & 43 deletions testOut.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,45 @@ Line no. Address Label Mnemonic Operands Comments
10 0003f1 LDA =X'5f'
11 0003f4 LDA =X'df'
12 0003f7 LDA =C'8j5'
***Invalid symbol name***
***Wrong operand prefix***
13 0003f7 LDT =C' '
14 0003fa LDA =W'1552'
15 0003fd LDA =W'-152'
16 000400 LDA =W'124'
17 000403 LDA =W'-152'
18 000406 LDA =W'1624'
19 000409 LDA =W'4095'
20 000409 .Format 4
21 00040c +SUB #12
22 000410 LDX #0
23 000413 LDCH HEXCHAR
24 000416 STA INPUT
25 000419 LOOP LDCH STRING,X
26 00041c COMP INPUT
28 000031 SAJED RESW NONE .Assumption
29 000801 SAJED1 RESW NONE .Assumption
30 1001a8 SAJED2 RESW NONE .Assumption
31 000095 SAJED3 RESW NONE .Assumption
32 0003e9 SAJED4 RESW NONE .Assumption
33 ffff41 SAJED5 RESW NONE .Assumption
13 0003fa LDA =C'8j5'
14 0003fd LDA =W'1552'
15 000400 LDA =W'-152'
16 000403 LDA =W'124'
17 000406 LDA =W'-152'
18 000409 LDA =W'1624'
19 00040c LDA =W'4095'
20 00040c .Format 4
21 00040f +SUB #12
22 000413 LDX #0
23 000416 LDCH HEXCHAR
24 000419 STA INPUT
25 00041c LOOP LDCH STRING,X
26 00041f COMP INPUT
28 000034 SAJED RESW NONE .Assumption
29 000804 SAJED1 RESW NONE .Assumption
30 100d60 SAJED2 RESW NONE .Assumption
31 000096 SAJED3 RESW NONE .Assumption
32 0003ec SAJED4 RESW NONE .Assumption
33 ffff3e SAJED5 RESW NONE .Assumption
34 fffc18 SAJED6 RESW NONE .Assumption
35 000031 SAJED7 RESW NONE .Assumption
35 00041f JEQ FOUND
36 000422 STCH OUTPUT,X
37 000425 TIX #5
38 000428 JLT LOOP
39 00042b FOUND J OUTPUT
40 00042e ALPHA WORD 2
41 000431 SAVEW RESW 2
42 000437 HEXCHAR BYTE X'6145fd56'
43 00043b INPUT RESB 1
44 00043c STRING BYTE X'F4'
45 00043d OUTPUT10 RESB 5
46 000442 =X'5f' BYTE X'5f'
46 000443 =X'df' BYTE X'df'
46 000444 =C'8j5' BYTE C'8j5'
46 000447 =W'1552' WORD 1552
46 00044a =W'-152' WORD -152
46 00044d =W'124' WORD 124
46 000450 =W'1624' WORD 1624
46 000453 =W'4095' WORD 4095
46 000456 END
35 000034 SAJED7 RESW NONE .Assumption
35 000422 JEQ FOUND
36 000425 STCH OUTPUT,X
37 000428 TIX #5
38 00042b JLT LOOP
39 00042e FOUND J OUTPUT
40 000431 ALPHA WORD 2
41 000434 SAVEW RESW 2
42 00043a HEXCHAR BYTE X'6145fd56'
43 00043e INPUT RESB 1
44 00043f STRING BYTE C'String'
45 000445 OUTPUT RESB 5
46 00044a =X'5f' BYTE X'5f'
46 00044b =X'df' BYTE X'df'
46 00044c =C'8j5' BYTE C'8j5'
46 00044f =W'1552' WORD 1552
46 000452 =W'-152' WORD -152
46 000455 =W'124' WORD 124
46 000458 =W'1624' WORD 1624
46 00045b =W'4095' WORD 4095
46 00045e END

0 comments on commit f3df144

Please sign in to comment.