1 Star 1 Fork 0

飘尘/WeiHaiMIPS译码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 44.00 KB
一键复制 编辑 原始数据 按行查看 历史
飘尘 提交于 2024-05-23 12:57 . update index.js.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584
/*
Written By: PiaoChen
Time: 2023-06-27
*/
class MsgShow {
constructor(mainId, time){
this.msgQueue = [];
this.index = 0;
this.container = document.getElementById(mainId);
this.aliveTime = time;
}
addMsg(content, type){
type = type || "info";
const msg = {
id: this.index,
content,
type
};
this.msgQueue.push(msg);
++this.index;
this.displayMsg(msg);
}
displayMsg(msg){
const span = document.createElement('span');
span.classList.add('copy-basic', `copy-${msg.type}`);
span.setAttribute('id', msg.id.toString());
span.innerHTML = msg.content;
this.container.appendChild(span);
setTimeout(() => {
this.container.removeChild(document.getElementById(msg.id.toString()));
this.msgQueue.shift();
}, this.aliveTime+20);
}
}
const msg = new MsgShow("container", 2000);
if(window.innerWidth <= 900){
alert("屏幕太小,未做移动适配可能影响展示,建议使用桌面端访问!");
}
function binary(number, bit) {
let binary = (number >>> 0).toString(2);
while (binary.length < bit) {
binary = '0' + binary;
}
while(binary.length > bit){
binary = binary.slice(1);
}
return binary;
}
function dec2bin(decNumber, bit) {
if (decNumber < 0) {
msg.addMsg("请输入一个非负整数", "error");
} else {
var q = binary(decNumber, bit);
return q;
}
}
function getNumber(s){
if(s.charAt(0)==="$"){
s = s.slice(1);
}
if(s.charAt(s.length-1) === ","){
s = s.substring(0, s.length - 1);
}
return Number.parseInt(s);
}
let input = document.getElementById("input");
let btn = document.getElementById("btn");
let result = document.getElementById("result");
let result16 = document.getElementById("result16");
const btnReset = document.getElementById("btn-reset");
/**
* 译码核心逻辑
* @returns {string}
*/
function getRes(){
result.innerHTML="";
result16.innerHTML="";
if(input.value === ""){
msg.addMsg("输入内容不能为空!", "error");
return;
}
let indexArr = input.value.split(" ");
let op = indexArr[0];
let numberArr = [];
let temp = []
var resArr;
switch (op){
case "add": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100000";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "addi": {
resArr = new Array(4)
resArr[0] = "001000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "addiu": {
resArr = new Array(4)
resArr[0] = "001001";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "addu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100001"
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "and": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100100"
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "andi": {
resArr = new Array(4)
resArr[0] = "001100";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "beq": {
resArr = new Array(4)
resArr[0] = "000100";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = temp[1];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "bgtz": {
resArr = new Array(4)
resArr[0] = "000111";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = "00000";
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "bltz": {
resArr = new Array(4)
resArr[0] = "000001";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = "00000";
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "bne": {
resArr = new Array(4)
resArr[0] = "000101";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = temp[1];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "j": {
resArr = new Array(2)
resArr[0] = "000010";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 26));
}
resArr[1] = temp[0];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "jal": {
resArr = new Array(2)
resArr[0] = "000011";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 26));
}
resArr[1] = temp[0];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "jr": {
resArr = new Array(4)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[0];
resArr[2] = "000000000000000";
resArr[3] = "001000";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "lbu": {
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "lhu": {
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "lui": {
resArr = new Array(4)
resArr[0] = "001111";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = "00000";
resArr[2] = temp[0];
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "lw": {
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "nor": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100111"
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "or": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100101"
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "ori": {
resArr = new Array(4)
resArr[0] = "001101";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sb": {
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "sh": {
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "sll": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000000";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sllv": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[2];
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "000100";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "slt": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "101010";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "slti": {
resArr = new Array(4)
resArr[0] = "001010";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sltiu": {
resArr = new Array(4)
resArr[0] = "001011";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sltu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "101011";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sra": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000011";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "srav": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[2];
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "000111";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "srl": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000010";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sub": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100010";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "subu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100011";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "sw":{
msg.addMsg("这个的处理逻辑没写", "error");
return;
}
case "xor": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100110";
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
case "xori": {
resArr = new Array(4)
resArr[0] = "001110";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
result.innerHTML+=resArr[i];
result.innerHTML+=" ";
}
break;
}
default: {
msg.addMsg("可能写错指令了,或者这个指令我没写逻辑...", "error");
return;
}
}
let str = ""
for(let i = 0; i<resArr.length; ++i){
str += resArr[i];
}
str = parseInt(str,2).toString(16);
let t = "";
if(str.length < 8){
for(let i = 0; i<8-str.length; ++i){
t += "0";
}
str = t + str;
}
result16.innerHTML = str.toUpperCase();
msg.addMsg("转换成功!", "success");
}
/**
* 文件译码核心逻辑,新加功能,懒得改了
* @param {string} item
* @returns {string}
*/
function getFileRes(item){
let indexArr = item.split(" ");
let op = indexArr[0];
let numberArr = [];
let temp = []
var resArr;
let parts = ""
switch (op){
case "add": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100000";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "addi": {
resArr = new Array(4)
resArr[0] = "001000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "addiu": {
resArr = new Array(4)
resArr[0] = "001001";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "addu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100001"
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "and": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100100"
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "andi": {
resArr = new Array(4)
resArr[0] = "001100";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "beq": {
resArr = new Array(4)
resArr[0] = "000100";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = temp[1];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "bgtz": {
resArr = new Array(4)
resArr[0] = "000111";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = "00000";
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "bltz": {
resArr = new Array(4)
resArr[0] = "000001";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = "00000";
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "bne": {
resArr = new Array(4)
resArr[0] = "000101";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i===2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[0];
resArr[2] = temp[1];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "j": {
resArr = new Array(2)
resArr[0] = "000010";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 26));
}
resArr[1] = temp[0];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "jal": {
resArr = new Array(2)
resArr[0] = "000011";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 26));
}
resArr[1] = temp[0];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "jr": {
resArr = new Array(4)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[0];
resArr[2] = "000000000000000";
resArr[3] = "001000";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "lbu": {
return `(lbu逻辑没写)-${item}`;
}
case "lhu": {
return `(lhu逻辑没写)-${item}`;
}
case "lui": {
resArr = new Array(4)
resArr[0] = "001111";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==1){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = "00000";
resArr[2] = temp[0];
resArr[3] = temp[1];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "lw": {
return `(lw逻辑没写)-${item}`;
}
case "nor": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100111"
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "or": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000"
resArr[5] = "100101"
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "ori": {
resArr = new Array(4)
resArr[0] = "001101";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sb": {
return `(sb的逻辑没写)-${item}`;
}
case "sh": {
return `(sh逻辑没写)-${item}`;
}
case "sll": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000000";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sllv": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[2];
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "000100";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "slt": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "101010";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "slti": {
resArr = new Array(4)
resArr[0] = "001010";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sltiu": {
resArr = new Array(4)
resArr[0] = "001011";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sltu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "101011";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sra": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000011";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "srav": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[2];
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "000111";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "srl": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = "00000";
resArr[2] = temp[1];
resArr[3] = temp[0];
resArr[4] = temp[2];
resArr[5] = "000010";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sub": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100010";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "subu": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100011";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "sw":{
return `(sw逻辑没写)-${item}`;
}
case "xor": {
resArr = new Array(6)
resArr[0] = "000000";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
temp.push(binary(numberArr[i], 5));
}
resArr[1] = temp[1];
resArr[2] = temp[2];
resArr[3] = temp[0];
resArr[4] = "00000";
resArr[5] = "100110";
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
case "xori": {
resArr = new Array(4)
resArr[0] = "001110";
for(let i = 1; i<indexArr.length; ++i){ // 把操作数拆出来
numberArr.push(getNumber(indexArr[i]));
}
for(let i = 0; i<numberArr.length; ++i){// 操作数转二进制
if(i==2){
temp.push(binary(numberArr[i], 16));
}else{
temp.push(binary(numberArr[i], 5));
}
}
resArr[1] = temp[1];
resArr[2] = temp[0];
resArr[3] = temp[2];
for(let i = 0; i<resArr.length; ++i){
parts+=resArr[i];
parts+=" ";
}
break;
}
default: {
return `没写这个-(${item})`;
}
}
let str = ""
for(let i = 0; i<resArr.length; ++i){
str += resArr[i];
}
str = parseInt(str,2).toString(16);
let t = "";
if(str.length < 8){
for(let i = 0; i<8-str.length; ++i){
t += "0";
}
str = t + str;
}
return str.toUpperCase();
}
// 转换得答案
btn.addEventListener("click", getRes);
// let s = "add $5, $6, $5";
// 使用须知
const explain = document.getElementById("explain");
explain.addEventListener('click', ()=>{ // 懒得写弹窗了
alert(`
使用须知:
⚠ 重要:请一定要确保转换前输入的指令格式是对的,指令格式要求必须要英文逗号并且逗号后面打一个空格,并且末尾不需要加任何东西!并且,本网页并没有实现全部的指令,有部分指令如lbu,sw,sh,sb,lw,lhu等没有写(因为老学长当年选的项目没用到这几个指令)。
⚠ 注意,如果指令是对的但是格式错误/部分使用方式错误情况,结果会出现undefined,但是如果是使用方式错了,本页面没有细致检查使用方式正确与否的功能,所以会正常译码,此时结果会看着没问题(但是这个就会出大问题了)
关于本网页:本网页是老学长自己写来自己用的(纯原生写的~),本着互帮互助的心态分享给大家。
本网页汇编命令转到机器码没有任何问题,已经经过了老学长亲自使用测试了,拿下了计组课设95+。
最后:加油各位!实在不会就什么chatGPT,New Bing,文心一言用起来啊!嘎嘎好用啊家人们!要是觉得好用的话不要忘了进老学长的仓库里给个star😁。
`);
});
// 重置功能
btnReset.addEventListener('click', ()=>{
input.value = "";
result.innerHTML="";
result16.innerHTML="";
msg.addMsg("重置成功!", "info");
});
// 点击复制
const copyItems = document.querySelectorAll(".res-res");
function doCopy(item) {
return async () => {
try {
const text = item.textContent;
await navigator.clipboard.writeText(text); // 实现复制到粘贴板
msg.addMsg('复制成功', 'success');
} catch (err) {
msg.addMsg('复制出现问题了!请重试', 'error');
console.error(err);
}
};
}
copyItems.forEach((item) => {// 绑上
item.addEventListener("click", doCopy(item));
});
// 右键粘贴
input.addEventListener('contextmenu', (e) => {
e.preventDefault(); // 阻止右键菜单
navigator.clipboard.readText()
.then(text => {
input.value = text;
msg.addMsg("粘贴成功!", "success");
})
.catch(err => {
msg.addMsg("访问粘贴板出错!", "error");
console.log(err);
return;
});
});
/**
* 生成下载文件
* @param {string[]} fileStringArr 文件内容数组
* @param {string} fileName 文件名
* @param {string} type 文件类型
*/
function letsDownloadFile(fileStringArr, fileName, type){
// 创建一个File对象
let file = new File(
fileStringArr,
fileName,
{
type,
}
);
// 创建一个指向File对象的URL
let url = URL.createObjectURL(file);
// 创建一个a标签并模拟点击来下载文件
let a = document.createElement("a");
a.href = url;
a.download = file.name;
a.click();
}
/**
* 解析字符串
* @param {string} fileString
* @returns {string} 直接可生成文件下载的内容
*/
function parseStr(fileString){
let strs = fileString.split("\r\n");
let res = "";
strs.forEach((item)=>{
if(item !== ""){
res += getFileRes(item.trim());
res += "\r\n";
}
});
return res;
}
// 拿到上传文件
const file = document.getElementById("file");
// 按钮
const templateBtn = document.getElementById("templateBtn");
templateBtn.addEventListener("click", ()=>{
alert(`
🧨文件格式:多个指令之前不需要添加分号,只需回车换行即可。除了指令之外,别的什么都不要有。
点击确定继续。
`);
letsDownloadFile(
[`add $5, $61, $5\r\nadd $15, $6, $5\r\nadd $5, $6, $9`],
"WeiHaiMIPS-template.txt",
"text/plain"
);
});
const uploadFileBtn = document.getElementById("fileBtn");
uploadFileBtn.addEventListener("click", ()=>{
alert(`
请注意,上传的文件必须符合格式要求的!检错不一定能检出来错误,格式错误甚至可能继续转换,导致机器码出错🧨!而这很难被发现。
内容将转换为16进制数。
无法处理汇编内容,跳转部分需要自己计算!
点击确定继续。(如果没继续让上传说明已经上传过一次了,刷新一下)
`);
file.click();
});
let fileString;
file.onchange = (e)=>{
const fileReader = new FileReader();
fileReader.readAsText(e.target.files[0]);
fileReader.onload = (e)=>{
fileString = e.target.result;
msg.addMsg("上传成功!", "success");
const result = parseStr(fileString);
msg.addMsg("转换完毕!", "success");
letsDownloadFile([result], "ResultOfWeiHaiMIPS.txt", "text/plain");
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/piao-chen/wei-hai-mips-decoding.git
git@gitee.com:piao-chen/wei-hai-mips-decoding.git
piao-chen
wei-hai-mips-decoding
WeiHaiMIPS译码
master

搜索帮助