I have some instructions for a cpu so i have assembly code and how can i translate them to machine code in java.
I have code like this:
LI 5
ST 1
AD 1
ST 0
LI 0
BZ 0
And i want to them like this:
85 41 c1 40 80 00
That assembly code stored in a txt file, so I have tried to reading that datas from txt file try {
String f = "C:\\Users\\comp\\Desktop\\CompArch\\a.txt";
FileReader fw = new FileReader(f);
BufferedReader assembly_file = new BufferedReader(fw);
Hashtable<String, String> symtab = new Hashtable<String, String>();
String str;
int z=0;
String f4 = "C:\\Users\\comp\\Desktop\\CompArch\\MACHINE_CODE.asm";
FileWriter fw4 = new FileWriter(f4);
BufferedWriter machine_code_file = new BufferedWriter(fw4);