[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Mips assembler in Cpp

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 5
Thread images: 1

File: mips_assembly.png (26KB, 708x211px) Image search: [Google]
mips_assembly.png
26KB, 708x211px
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;
}
>>
>>56240526
neat
>>>/g/dpt
>>
>>56240526
Wew lad, ever heard of switch?
>>
>>56240526
working on an assembler for a verilog/vhdl FPGA project, are we?
>>
>>56240546
It keeps giving me the error that i cant use $ although it's a string
Thread posts: 5
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.