Skip to content

Commit

Permalink
cleaning main func
Browse files Browse the repository at this point in the history
  • Loading branch information
NumanAnees committed May 22, 2021
1 parent dee5a87 commit 1529138
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 16 deletions.
28 changes: 15 additions & 13 deletions Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,9 @@ string functionForC(string s)
Bits_16 = Bits_16 + J_Code(jump); //concatinate the 13 bits with 3 bits of jump
return Bits_16; //return the 16 bits number which we can write into file later on
}
//----------------------------------------------Handling file----------------------------------------------------

//-----------------------------------------------main func()-----------------------------------------------------

int main()
{
string filename;
cout << "Enter the File name : "; //open the appropriate file
cin >> filename;
filename = filename.substr(0, filename.find('.')); //if you enter test.asm this instruction filter it to test
string hack;
hack = filename + ".hack"; //filtered test+.hack makes test.hack
//cout << hack << endl << filename;
//reading the asm file 👍
void Files(string filename,string hack){
fstream assemblyFile, outputFile; //.asm and hack files
assemblyFile.open(filename + ".asm", ios::in);
outputFile.open(hack, ios::out);
Expand Down Expand Up @@ -337,6 +327,18 @@ int main()

outputFile.close(); //closing the files
assemblyFile.close(); //closing the files
}
}
}
//-----------------------------------------------main func()-----------------------------------------------------

int main()
{
string filename;
cout << "Enter the File name : "; //open the appropriate file
cin >> filename;
filename = filename.substr(0, filename.find('.')); //if you enter test.asm this instruction filter it to test
string hack;
hack = filename + ".hack"; //then the filtered test is concatenated with .hack
Files(filename,hack); //calling the function it will handle everything
return 0;
}
Binary file added Assembler.exe
Binary file not shown.
5 changes: 2 additions & 3 deletions test.asm
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ D;JEQ
@New
D=M
@Y
M=M+D
M=D+M
@Temp3
M=M-1
@LOOP3
0;JMP
(End)
@End
0;JMP

0;JMP
67 changes: 67 additions & 0 deletions test.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
0000000000001000
1110110000010000
0000000000010000
1110001100001000
0000000000001001
1110110000010000
0000000000010001
1110001100001000
0000000000010000
1111110000010000
0000000000010010
1110001100001000
0000000000010001
1111110000010000
0000000000010011
1110001100001000
0000000000010011
1111110000010000
0000000000011010
1110001100000010
0000000000010010
1111110111001000
0000000000010011
1111110010001000
0000000000010000
1110101010000111
0000000000010000
1111110000010000
0000000000010100
1110001100001000
0000000000010010
1111110000010000
0000000000010101
1110001100001000
0000000000010100
1111110000010000
0000000000101100
1110001100000010
0000000000010101
1111110111001000
0000000000010100
1111110010001000
0000000000100010
1110101010000111
0000000000010001
1111110000010000
0000000000010110
1110001100001000
1111110010001000
0000000000010101
1111110000010000
0000000000010111
1110001100001000
0000000000010110
1111110000010000
0000000001000001
1110001100000010
0000000000010111
1111110000010000
0000000000010101
1111000010001000
0000000000010110
1111110010001000
0000000000110101
1110101010000111
0000000001000001
1110101010000111

0 comments on commit 1529138

Please # to comment.