I'm trying to make a program that converts Mips assembly code to its hexadecimal format
example:
Input: addi $s0, $s0, -16
Output: 2210fff0
This is what i have this far
cout<<"Select the type that you want to change to Machine code:"<<endl<<"1.R-type"<<endl<<"2.I-type"<<endl<<"3.J-type"<<endl<<endl;
cin>>choice;
system("CLS");
switch (choice) {
case 1:
shamt=0;
op_code=0;
cout<<"Enter the fun code: "<<endl;
cin>>fun;
if(fun=="Add")
cout<<"32"<<endl;
else if (fun=="Sub")
cout<<"34"<<endl;
else if (fun=="And")
cout<<"36"<<endl;
else if(fun=="Or")
cout<<"37"<<endl;
else if (fun=="Nor")
cout<<"39"<<endl;
}
cout<<"Enter the registers (r2 , r3 , r1):"<<endl;
cin>>r2;
if (r2=="$t0")
cout<<"8"<<endl;
else if (r2=="$t1")
cout<<"9"<<endl;
else if (r2=="$t2")
cout<<"10"<<endl;
else if (r2=="$t3")
cout<<"11"<<endl;
else if (r2=="$t4")
cout<<"12"<<endl;
else if (r2=="$t5")
cout<<"13"<<endl;
else if (r2=="$t6")
cout<<"14"<<endl;
else if (r2=="$t7")
cout<<"15"<<endl;
//else if (r2=='$t1')
//cout<<"9"<<endl;
/*cout<<r2,r3,r1;
break;
case 2:
cout<<"wait";
break;
case 3:
break;
}*/
return 0;
}