mips机器码翻译器(修正一)

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

include
include
include
include
include <龙芯.h>
FILE *fp1,*fp2;
char du[],A[10],B[26],C[2],D[16],E[16];
int cuo,jiewei;
int main(int argc,char *argv[])
{
if (3!=argc)
{
printf ("参数格式不正确");
exit (1);
}
if ((fp1=fopen (argv[1]))==NULL)
{
printf ("打开失败.请检查打开文件路径\n");
exit (1);
}
if ((fp2=fopen (argv[2]))==NULL)
{
printf ("创建文件失败.请检查创建的文件名\n");
exit(1);
}
do
{
fgets (du,400,fp1);
A=strtok (du," ");
B=strtok (NULL," ");
switch (A)
{
case "ABS.S":
C=strtok (B,",");
D=strtok (NULL,",");
ABS.S.fd=atoi(C);
ABS.S.fs=atoi(D);
fwrite(ABS.S,4,1,fp2);
break;
case "ABS.D":
C=strtok(B,",");
D=strtok(NULL,",");
ABS.D.fd=atoi(C);
ABS.D.fs=atoi(D);
fwrite(ABS.D,4,1,fp2);
break;
case "BC1F":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC1F.offset=atoi(C);
goto bc1f;
}
=atoi(C);
BC1F.offset=atoi(D);
bc1f:fwrite(BC1F,4,1,fp2);
break;
case "BC1FL":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC1FL.offset=atoi(C);
goto bc1fl;
}
=atoi(C);
BC1FL.offset=atoi(D);
bc1fl:fwrite(BC1FL,4,1,fp2);
break;
case "BC1T":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC1T.offset=atoi(C);
goto bc1t;
}
=atoi(C);
BC1T.offset=atoi(D);
bc1t:fwrite(BC1T,4,1,fp2);
break;
case "BC1TL":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC1TL.offset=atoi(C);
goto bc1tl;
}
=atoi(C);
BC1TL.offset=atoi(D);
bc1tl:fwrite(BC1TL,4,1,fp2);
break;
case "BC2F":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC2F.offset=atoi(C);
goto bc2f;
}
=atoi(C);
BC2F.offset=atoi(D);
bc2f:fwrite(BC2F,4,1,fp2);
break;
case "BC2FL":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC2FL.offset=atoi(C);
goto bc2fl;
}
=atoi(C);
BC2FL.offset=atoi(D);
bc2fl:fwrite(BC2FL,4,1,fp2);
break;
case "BC2T":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC2T.offset=atoi(C);
goto bc2t;
}
=atoi(C);
BC2T.offset=atoi(D);
bc2t:fwrite(BC2T,4,1,fp2);
break;
case "BC2TL":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
BC2TL.offset=atoi(C);
goto bc2tl;
}
=atoi(C);
BC2TL.offset=atoi(D);
bc2tl:fwrite(BC2TL,4,1,fp2);
break;
case "BGEZ":
C=strtok(B,",");
D=strtok(NULL,",");
BGEZ.rs=atoi(C);
BGEZ.offset=atoi(D);
fwrite(BGEZ,4,1,fp2);
break;
case "BGEZAL":
C=strtok(B,",");
D=strtok(NULL,",");
BGEZAL.rs=atoi(C);
BGEZAL.offset=atoi(D);
fwrite(BGEZAL,4,1,fp2);
break;
case "BGEZALL":
C=strtok(B,",");
D=strtok(NULL,",");
BGEZALL.rs=atoi(C);
BGEZALL.offset=atoi(D);
fwrite(BGEZALL,4,1,fp2);
break;
case "BGEZL":
C=strtok(B,",");
D=strtok(NULL,",");
BGEZL.rs=atoi(C);
BGEZL.offset=atoi(D);
fwrite(BGEZL,4,1,fp2);
break;
case "BGTZ":
C=strtok(B,",");
D=strtok(NULL,",");
BGTZ.rs=atoi(C);
BGTZ.offset=atoi(D);
fwrite(BGTZ,4,1,fp2);
break;
case "BGTZL":
C=strtok(B,",")

;
D=strtok(NULL,",");
BGTZL.rs=atoi(C);
BGTZL.offset=atoi(D);
fwrite(BGTZL,4,1,fp2);
break;
case "BLEZ":
C=strtok(B,",");
D=strtok(NULL,",");
BLEZ.rs=atoi(C);
BLEZ.offset=atoi(D);
fwrite(BLEZ,4,1,fp2);
break;
case "BLEZL":
C=strtok(B,",");
D=strtok(NULL,",");
BLEZL.rs=atoi(C);
BLEZL.offset=atoi(D);
fwrite(BLEZL,4,1,fp2);
break;
case "BLTZ":
C=strtok(B,",");
D=strtok(NULL,",");
BLTZ.rs=atoi(C);
BLTZ.offset=atoi(D);
fwrite(BLTZ,4,1,fp2);
break;
case "BLTZAL":
C=strtok(B,",");
D=strtok(NULL,",");
BLTZAL.rs=atoi(C);
BLTZAL.offset=atoi(D);
fwrite(BLTZAL,4,1,fp2);
break;
case "BLTZALL":
C=strtok(B,",");
D=strtok(NULL,",");
BLTZALL.rs=atoi(C);
BLTZALL.offset=atoi(D);
fwrite(BLTZALL,4,1,fp2);
break;
case "BLTZL":
C=strtok(B,",");
D=strtok(NULL,",");
BLTZL.rs=atoi(C);
BLTZL.offset=atoi(D);
fwrite(BLTZL,4,1,fp2);
break;
case "CEIL.W.S":
C=strtok(B,",");
D=strtok(NULL,",");
CEIL.W.S.fd=atoi(C);
CEIL.W.S.fs=atoi(D);
fwrite(CEIL.W.S,4,1,fp2);
break;
case "CEIL.W.D":
C=strtok(B,",");
D=strtok(NULL,",");
CEIL.W.D.fd=atoi(C);
CEIL.W.D.fs=atoi(D);
fwrite(CEIL.W.D,4,1,fp2);
break;
case "CFC1":
C=strtok(B,",");
D=strtok(NULL,",");
CFC1.rt=atoi(C);
CFC1.fs=atoi(D);
fwrite(CFC1,4,1,fp2);
break;
case "CFC2":
C=strtok(B,",");
D=strtok(NULL,",");
CFC2.rt=atoi(C);
CFC2.rd=atoi(D);
fwrite(CFC2,4,1,fp2);
break;
case "CLO":
C=strtok(B,",");
D=strtok(NULL,",");
CLO.rd=atoi(C);
CLO.rs=atoi(D);
fwrite(CLO,4,1,fp2);
break;
case "CLZ":
C=strtok(B,",");
D=strtok(NULL,",");
CLZ.rd=atoi(C);
CLZ.rs=atoi(D);
fwrite(CLZ,4,1,fp2);
break;
case "CTC1":
C=strtok(B,",");
D=strtok(NULL,",");
CTC1.rt=atoi(C);
CTC1.fs=atoi(D);
fwrite(CTC1,4,1,fp2);
break;
case "CTC2":
C=strtok(B,",");
D=strtok(NULL,",");
CTC2.rt=atoi(C);
CTC2.fs=atoi(D);
fwrite(CTC2,4,1,fp2);
break;
case "CVT.D.S":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.D.S.fd=atoi(C);
CVT.D.S.fs=atoi(D);
fwrite(CVT.D.S,4,1,fp2);
break;
case "CVT.D.W":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.D.W.fd=atoi(C);
CVT.D.W.fs=atoi(D);
fwrite(CVT.D.W,4,1,fp2);
break;
case "CVT.D.L":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.D.L.fd=atoi(C);
CVT.D.L.fs=atoi(D);
fwrite(CVT.D.L,4,1,fp2);
break;
case "CVT.S.S":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.S.S.fd=atoi(C);
CVT.S.S.fs=atoi(D);
fwrite(CVT.S.S,4,1,fp2);
break;
case "CVT.S.W":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.S.W.fd=atoi(C);
CVT.S.W.fs=atoi(D);
fwrite(CVT.S.W,4,1,fp2);
break;
case "CVT.S.L":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.S.L.fd=atoi(C);
CVT.S.L.fs=atoi(D);
fwrite(CVT.S.L,4,1,fp2);
break;
case "CVT.W.S":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.W.S.fd=atoi(C);
CVT.W.S.fs=atoi(D);
fwrite(CVT.W.S,4,1,fp2);
break;
case "CVT.W":
C=strtok(B,",");
D=strtok(NULL,",");
CVT.W.D.fd=atoi(C);
CVT.W.D.fs=atoi(D);
fwrite(CVT.W.D,4,1,fp2);
break;
case "DIV":
C=strtok(B,",");
D=strtok(NULL,",");
DIV.rs=atoi(C);

DIV.rt=atoi(D);
fwrite(DIV,4,1,fp2);
break;
case "DIVU":
C=strtok(B,",");
D=strtok(NULL,",");
DIVU.rs=atoi(C);
DIVU.rt=atoi(D);
fwrite(DIVU,4,1,fp2);
break;
case "FLOOR.W.S":
C=strtok(B,",");
D=strtok(NULL,",");
FLOOR.W.S.fd=atoi(C);
FLOOR.W.S.fs=atoi(D);
fwrite(FLOOR.W.S,4,1,fp2);
break;
case "FLOOR.W.D":
C=strtok(B,",");
D=strtok(NULL,",");
FLOOR.W.D.fd=atoi(C);
FLOOR.W.D.fs=atoi(D);
fwrite(FLOOR.W.D,4,1,fp2);
break;
case "JALR":
C=strtok(B,",");
D=strtok(NULL,",");
if(D==NULL)
{
JALR.rd=31;
JALR.rs=atoi(C);
goto jalr;
};
JALR.rd=atoi(C);
JALR.rs=atoi(D);
jalr:fwrite(JALR,4,1,fp2);
break;
case "LUI":
C=strtok(B,",");
D=strtok(NULL,",");
LUI.rt=atoi(C);
LUI.imm=atoi(D);
fwrite(LUI,4,1,fp2);
break;
case "MADD":
C=strtok(B,",");
D=strtok(NULL,",");
MADD.rs=atoi(C);
MADD.rt=atoi(D);
fwrite(MADD,4,1,fp2);
break;
case "MADDU":
C=strtok(B,",");
D=strtok(NULL,",");
MADDU.rs=atoi(C);
MADDU.rt=atoi(D);
fwrite(MADDU,4,1,fp2);
break;
case "MFC1":
C=strtok(B,",");
D=strtok(NULL,",");
MFC1.rt=atoi(C);
MFC1.fs=atoi(D);
fwrite(MFC1,4,1,fp2);
break;
case "MOV.S":
C=strtok(B,",");
D=strtok(NULL,",");
MOV.S.fd=atoi(C);
MOV.S.fs=atoi(D);
fwrite(MOV.S,4,1,fp2);
break;
case "MOV.D":
C=strtok(B,",");
D=strtok(NULL,",");
MOV.D.fd=atoi(C);
MOV.D.fs=atoi(D);
fwrite(ABS.D,4,1,fp2);
break;
case "MSUB":
C=strtok(B,",");
D=strtok(NULL,",");
MSUB.rs=atoi(C);
MSUB.rt=atoi(D);
fwrite(MSUB,4,1,fp2);
break;
case "MSUBU":
C=strtok(B,",");
D=strtok(NULL,",");
MSUBU.rs=atoi(C);
MSUBU.rt=atoi(D);
fwrite(MSUBU,4,1,fp2);
break;
case "MTC1":
C=strtok(B,",");
D=strtok(NULL,",");
MTC1.rt=atoi(C);
MTC1.fs=atoi(D);
fwrite(MTC1,4,1,fp2);
break;
case "MULT":
C=strtok(B,",");
D=strtok(NULL,",");
MULT.rs=atoi(C);
MULT.rt=atoi(D);
fwrite(MULT,4,1,fp2);
break;
case "MULTU":
C=strtok(B,",");
D=strtok(NULL,",");
MULTU.rs=atoi(C);
MULTU.rt=atoi(D);
fwrite(MULTU,4,1,fp2);
break;
case "NEG.S":
C=strtok(B,",");
D=strtok(NULL,",");
NEG.S.fd=atoi(C);
NEG.S.fs=atoi(D);
fwrite(NEG.S,4,1,fp2);
break;
case "NEG.D":
C=strtok(B,",");
D=strtok(NULL,",");
NEG.D.fd=atoi(C);
NEG.D.fs=atoi(D);
fwrite(NEG.D,4,1,fp2);
break;
case "ROUND.W.S":
C=strtok(B,",");
D=strtok(NULL,",");
ROUND.W.S.fd=atoi(C);
ROUND.W.S.fs=atoi(D);
fwrite(ROUND.W.S,4,1,fp2);
break;
case "ROUND.W.D":
C=strtok(B,",");
D=strtok(NULL,",");
ROUND.W.D.fd=atoi(C);
ROUND.W.D.fs=atoi(D);
fwrite(ROUND.W.D,4,1,fp2);
break;
case "SQRT.S":
C=strtok(B,",");
D=strtok(NULL,",");
SQRT.S.fd=atoi(C);
SQRT.S.fs=atoi(D);
fwrite(SQRT.S,4,1,fp2);
break;
case "SQRT.D":
C=strtok(B,",");
D=strtok(NULL,",");
SQRT.D.fd=atoi(C);
SQRT.D.fs=atoi(D);
fwrite(SQRT.D,4,1,fp2);
break;
case "TEQI":
C=strtok(B,",");
D=strtok(NULL,",");
TEQI.rs=atoi(C);
TEQI.imm=atoi(D);
fwrite(TEQI,4,1,fp2);
break;
case "TGEI":
C=strtok(B,",");
D=strtok(NULL,",");
TGEI.rs=atoi(C);
TGEI.imm=atoi(D);
fwrite(TGEI,

4,1,fp2);
break;
case "TGEIU":
C=strtok(B,",");
D=strtok(NULL,",");
TGEIU.rs=atoi(C);
TGEIU.imm=atoi(D);
fwrite(TGEIU,4,1,fp2);
break;
case "TLTI":
C=strtok(B,",");
D=strtok(NULL,",");
TLTI.rs=atoi(C);
TLTI.imm=atoi(D);
fwrite(TLTI,4,1,fp2);
break;
case "TLTIU":
C=strtok(B,",");
D=strtok(NULL,",");
TLTIU.rs=atoi(C);
TLTIU.imm=atoi(D);
fwrite(TLTIU,4,1,fp2);
break;
case "TNEI":
C=strtok(B,",");
D=strtok(NULL,",");
TNEI.rs=atoi(C);
TNEI.imm=atoi(D);
fwrite(TNEI,4,1,fp2);
break;
case "TRUNC.W.S":
C=strtok(B,",");
D=strtok(NULL,",");
TRUNC.W.S.fd=atoi(C);
TRUNC.W.S.fs=atoi(D);
fwrite(TRUNC.W.S,4,1,fp2);
break;
case "TRUNC.W.D":
C=strtok(B,",");
D=strtok(NULL,",");
TRUNC.W.D.fd=atoi(C);
TRUNC.W.D.fs=atoi(D);
fwrite(TRUNC.W.D,4,1,fp2);
break;
case "B":
B.offset=atoi(B);
fwrite(B,4,1,4,1,fp2);
break;
case "BAL":
BAL.offset=atoi(B);
fwrite(BAL,4,1,fp2);
break;
case "BREAK":
if(B[0]!='#')
{
BREAK.code=atoi(B);
}
fwrite(BREAK,4,1,fp2);
break;
case "COP2":
if(B[0]!='#')
{
COP2.func=atoi(B);
}
fwrite(COP2,4,1,fp2);
break;
case "J":
J.target=atoi(B);
fwrite(J,4,1,fp2);
break;
case "JAL":
JAL.target=atoi(B);
fwrite(JAL,4,1,fp2);
break;
case "JR":
JR.rs=atoi(B);
fwrite(JR,4,1,fp2);
break;
case "MFHI":
MFHI.rd=atoi(B);
fwrite(MFHI,4,1,fp2);
break;
case "MFLO":
MFLO.rd=atoi(B);
fwrite(MFLO,4,1,fp2);
break;
case "MTHI":
MTHI.rs=atoi(B);
fwrite(MTHI,4,1,fp2);
break;
case "MTLO":
MTLO.rs=atoi(B);
fwrite(MTLO,4,1,fp2);
break;
case "SDBBP":
if(B[0]!='#')
{
SDBBP.code=atoi(B);
}
fwrite(SDBBP,4,1,fp2);
break;
case "SYNC":
if(B[0]!='#')
{
SYNC.stype=atoi(B);
}
fwrite(SYNC,4,1,fp2);
break;
case "SYSCALL":
if(B[0]!='#')
{
SYSCALL.code=atoi(B);
}
fwrite(SYSCALL,4,1,fp2);
break;
p case "WAIT":
if(B[0]!='#')
{
WAIT.Code=atoi(B);
}
fwrite(WAIT,4,1,fp2);
break;
case "SSNOP":
fwrite(SSNOP,4,1,fp2);
break;
case "NOP":
fwrite(NOP,4,1,fp2);
break;
case "ERET":
fwrite(ERET,4,1,fp2);
break;
case "DERET":
fwrite(DERET,4,1,fp2);
break;
case "ADD":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADD.rd=atoi(C);
ADD.rs=atoi(D);
ADD.rt=atoi(E);
fwrite(ADD,4,1,fp2);
break;
case "ADD.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADD.S.fd=atoi(C);
ADD.S.fs=atoi(D);
ADD.S.ft=atoi(E);
fwrite(ADD.S,4,1,fp2);
break;
case "ADD.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADD.D.fd=atoi(C);
ADD.D.fs=atoi(D);
ADD.D.ft=atoi(E);
fwrite(ADD.D,4,1,fp2);
break;
case "ADDI":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADDI.rt=atoi(C);
ADDI.rs=atoi(D);
ADDI.imm=atoi(E);
fwrite(ADDI,4,1,fp2);
break;
case "ADDIU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADDIU.rt=atoi(C);
ADDIU.rs=atoi(D);
ADDIU.imm=atoi(E);
fwrite(ADDIU,4,1,fp2);
break;
case "ADDU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADDU.rd=atoi(C);
ADDU.rs=atoi(D);

ADDU.rt=atoi(E);
fwrite(ADDU,4,1,fp2);
break;
case "AND":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
AND.rd=atoi(C);
AND.rs=atoi(D);
AND.rt=atoi(E);
fwrite(AND,4,1,fp2);
break;
case "ANDI":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ANDI.rt=atoi(C);
ANDI.rs=atoi(D);
ANDI.imm=atoi(E);
fwrite(ANDI,4,1,fp2);
break;
case "BEQ":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
BEQ.rs=atoi(C);
BEQ.rt=atoi(D);
BEQ.offset=atoi(E);
fwrite(BEQ,4,1,fp2);
break;
case "BEQL":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
BEQL.rs=atoi(C);
BEQL.rt=atoi(D);
BEQL.offset=atoi(E);
fwrite(BEQL,4,1,fp2);
break;
case "BNE":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
BNE.rs=atoi(C);
BNE.rt=atoi(D);
BNE.imm=atoi(E);
fwrite(BNE,4,1,fp2);
break;
case "BNEL":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
BNEL.rs=atoi(C);
BNEL.rt=atoi(D);
BNEL.imm=atoi(E);
fwrite(BNEL,4,1,fp2);
break;
case "C.F.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.F.S.fs=atoi(C);
C.F.S.ft=atoi(D);
goto c.f.s;
};
=atoi(C);
C.F.S.fs=atoi(D);
C.F.S.ft=atoi(E);
c.f.s:fwrite(C.F.S,4,1,fp2);
break;
case "C.F.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.F.D.fs=atoi(C);
C.F.D.ft=atoi(D);
goto c.f.d;
}
=atoi(C);
C.F.D.fs=atoi(D);
C.F.D.ft=atoi(E);
c.f.d:fwrite(C.F.D,4,1,fp2);
break;
case "C.UN.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.UN.S.fs=atoi(C);
C.UN.S.ft=atoi(D);
goto c.un.s;
}
=atoi(C);
C.UN.S.fs=atoi(D);
C.UN.S.ft=atoi(E);
c.un.s:fwrite(C.UN.S,4,1,fp2);
break;
case "C.UN.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.UN.D.fs=atoi(C);
C.UN.D.ft=atoi(D);
goto c.un.d;
}
=atoi(C);
C.UN.D.fs=atoi(D);
C.UN.D.ft=atoi(E);
c.un.d:fwrite(C.UN.D,4,1,fp2);
break;
case "C.EQ.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.EQ.S.fs=atoi(C);
C.EQ.S.ft=atoi(D);
goto c.eq.s;
}
=atoi(C);
C.EQ.S.fs=atoi(D);
C.EQ.S.ft=atoi(E);
c.eq.s:fwrite(C.EQ.S,4,1,fp2);
break;
case "C.EQ.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.EQ.D.fs=atoi(C);
C.EQ.D.ft=atoi(D);
goto c.eq.d;
}
=atoi(C);
C.EQ.D.fs=atoi(D);
C.EQ.D.ft=atoi(E);
c.eq.d:fwrite(C.EQ.D,4,1,fp2);
break;
case "C.UEQ.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.UEQ.S.fs=atoi(C);
C.UEQ.S.ft=atoi(D);
goto c.ueq.s;
}
=atoi(C);
C.UEQ.S.fs=atoi(D);
C.UEQ.S.ft=atoi(E);
c.ueq.s:fwrite(C.UEQ.S,4,1,fp2);
break;
case "C.UEQ.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.UEQ.D.fs=atoi(C);
C.UEQ.D.ft=atoi(D);
goto c.ueq.d;
}
=atoi(C);
C.UEQ.D.fs=atoi(D);
C.UEQ.D.ft=atoi(E);
c.ueq.d:fwrite(C.UEQ.D,4,1,fp2);
break;
case "C

.OLT.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.OLT.S.fs=atoi(C);
C.OLT.S.ft=atoi(D);
goto c.olt.s;
}
=atoi(C);
C.OLT.S.fs=atoi(D);
C.OLT.S.ft=atoi(E);
c.olt.s:fwrite(C.OLT.S,4,1,fp2);
break;
case "C.OLT.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.OLT.D.fs=atoi(C);
C.OLT.D.ft=atoi(D);
goto c.olt.d;
}
=atoi(C);
C.OLT.D.fs=atoi(D);
C.OLT.D.ft=atoi(E);
c.olt.d:fwrite(C.OLT.D,4,1,fp2);
break;
case "C.ULT.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.ULT.S.fs=atoi(C);
C.ULT.S.ft=atoi(D);
goto c.ult.s;
}
=atoi(C);
C.ULT.S.fs=atoi(D);
C.ULT.S.ft=atoi(E);
c.ult.s:fwrite(C.ULT.S,4,1,fp2);
break;
case "C.ULT.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.ULT.D.fs=atoi(C);
C.ULT.D.ft=atoi(D);
goto c.ult.d;
}
=atoi(C);
C.ULT.D.fs=atoi(D);
C.ULT.D.ft=atoi(E);
c.ult.d:fwrite(C.ULT.D,4,1,fp2);
break;
case "C.OLE.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.OLE.S.fs=atoi(C);
C.OLE.S.ft=atoi(D);
goto c.ole.s;
}
=atoi(C);
C.OLE.S.fs=atoi(D);
C.OLE.S.ft=atoi(E);
c.ole.s:fwrite(C.OLE.S,4,1,fp2);
break;
case "C.OLE.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.OLE.D.fs=atoi(C);
C.OLE.D.ft=atoi(D);
goto c.ole.d;
}
=atoi(C);
C.OLE.D.fs=atoi(D);
C.OLE.D.ft=atoi(E);
c.ole.d:fwrite(C.OLE.D,4,1,fp2);
break;
case "C.ULE.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.ULE.S.fs=atoi(C);
C.ULE.S.ft=atoi(D);
goto c.ule.s;
}
=atoi(C);
C.ULE.S.fs=atoi(D);
C.ULE.S.ft=atoi(E);
c.ule.s:fwrite(C.ULE.S,4,1,fp2);
break;
case "C.ULE.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.ULE.D.fs=atoi(C);
C.ULE.D.ft=atoi(D);
goto c.ule.d;
}
=atoi(C);
C.ULE.D.fs=atoi(D);
C.ULE.D.ft=atoi(E);
c.ule.d:fwrite(C.ULE.D,4,1,fp2);
break;
case "C.SF.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.SF.S.fs=atoi(C);
C.SF.S.ft=atoi(D);
goto c.sf.s;
}
=atoi(C);
C.SF.S.fs=atoi(D);
C.SF.S.ft=atoi(E);
c.sf.s:fwrite(C.SF.S,4,1,fp2);
break;
case "C.SF.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.SF.D.fs=atoi(C);
C.SF.D.ft=atoi(D);
goto c.sf.d;
}
=atoi(C);
C.SF.D.fs=atoi(D);
C.SF.D.ft=atoi(E);
c.sf.d:fwrite(C.SF.D,4,1,fp2);
break;
case "C.NGLE.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGLE.S.fs=atoi(C);
C.NGLE.S.ft=atoi(D);
goto c.ngle.s;
}
=atoi(C);
C.NGLE.S.fs=atoi(D);
C.NGLE.S.ft=atoi(E);
c.ngle.d:fwrite(C.NGLE.S,4,1,fp2);
break;
case "C.NGLE.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGLE.D.fs=atoi(C);
C.NGLE.D.ft=atoi(D);
goto c.ngle.d;
}
=atoi(C);

C.NGLE.D.fs=atoi(D);
C.NGLE.D.ft=atoi(E);
c.ngle:fwrite(C.NGLE.D,4,1,fp2);
break;
case "C.SEQ.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.SEQ.S.fs=atoi(C);
C.SEQ.S.ft=atoi(D);
goto c.seq.s;
}
=atoi(C);
C.SEQ.S.fs=atoi(D);
C.SEQ.S.ft=atoi(E);
c.seq.s:fwrite(C.SEQ.S,4,1,fp2);
break;
case "C.SEQ.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.SEQ.D.fs=atoi(C);
C.SEQ.D.ft=atoi(D);
goto c.seq.d;
}
=atoi(C);
C.SEQ.D.fs=atoi(D);
C.SEQ.D.ft=atoi(E);
c.seq.d:fwrite(C.SEQ.D,4,1,fp2);
break;
case "C.NGL.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGL.S.fs=atoi(C);
C.NGL.S.ft=atoi(D);
goto c.ngl.s;
}
=atoi(C);
C.NGL.S.fs=atoi(D);
C.NGL.S.ft=atoi(E);
c.ngl.s:fwrite(C.NGL.S,4,1,fp2);
break;
case "C.NGL.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGL.D.fs=atoi(C);
C.NGL.D.ft=atoi(D);
goto c.ngl.d;
}
=atoi(C);
C.NGL.D.fs=atoi(D);
C.NGL.D.ft=atoi(E);
c.ngl.d:fwrite(C.NGL.D,4,1,fp2);
break;
case "C.LT.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.LT.S.fs=atoi(C);
C.LT.S.ft=atoi(D);
goto c.lt.s;
}
=atoi(C);
C.LT.S.fs=atoi(D);
C.LT.S.ft=atoi(E);
c.lt.s:fwrite(C.LT.S,4,1,fp2);
break;
case "C.LT.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.LT.D.fs=atoi(C);
C.LT.D.ft=atoi(D);
goto c.lt.d;
}
=atoi(C);
C.LT.D.fs=atoi(D);
C.LT.D.ft=atoi(E);
c.lt.d:fwrite(C.LT.D,4,1,fp2);
break;
case "C.NGE.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGE.S.fs=atoi(C);
C.NGE.S.ft=atoi(D);
goto c.nge.s;
}
=atoi(C);
C.NGE.S.fs=atoi(D);
C.NGE.S.ft=atoi(E);
c.nge.s:fwrite(C.NGE.S,4,1,fp2);
break;
case "C.NGE.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGE.D.fs=atoi(C);
C.NGE.D.ft=atoi(D);
goto c.nge.d;
}
=atoi(C);
C.NGE.D.fs=atoi(D);
C.NGE.D.ft=atoi(E);
c.nge.d:fwrite(C.NGE.D,4,1,fp2);
break;
case "C.LE.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.LE.S.fs=atoi(C);
C.LE.S.ft=atoi(D);
goto c.le.s;
}
C.LE =atoi(C);
C.LE.S.fs=atoi(D);
C.LE.S.ft=atoi(E);
c.le.s:fwrite(C.LE.S,4,1,fp2);
break;
case "C.LE.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.LE.D.fs=atoi(C);
C.LE.D.ft=atoi(D);
goto c.le.d;
}
=atoi(C);
C.LE.D.fs=atoi(D);
C.LE.D.ft=atoi(E);
c.le.d:fwrite(C.LE.D,4,1,fp2);
break;
case "C.NGT.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGT.S.fs=atoi(C);
C.NGT.S.ft=atoi(D);
goto c.ngt.s;
}
=atoi(C);
C.NGT.S.fs=atoi(D);
C.NGT.S.ft=atoi(E);
c.ngt.s:fwrite(C.NGT.S,4,1,fp2);
break;
case "C.NGT.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
if(E==NULL)
{
C.NGT.D.fs=atoi(C)

;
C.NGT.D.ft=atoi(D);
goto c.ngt.d;
}
=atoi(C);
C.NGT.D.fs=atoi(D);
C.NGT.D.ft=atoi(E);
c.ngt.d:fwrite(C.NGT.D,4,1,fp2);
break;
case "CACHE":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
CACHE.op=atoi(C);
CACHE.offset=atoi(D);
CACHE.base=atoi(E);
fwrite(CACHE,4,1,fp2);
break;
case "DIV.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DIV.fd=atoi(C);
DIV.fs=atoi(D);
DIV.ft=atoi(E);
fwrite(DIV.S,4,1,fp2);
break;
case "DIV.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DIV.D.fd=atoi(C);
DIV.D.fs=atoi(D);
DIV.D.ft=atoi(E);
fwrite(DIV.D,4,1,fp2);
break;
case "LB":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LB.rt=atoi(C);
LB.offset=atoi(D);
LB.base=atoi(E);
fwrite(LB,4,1,fp2);
break;
case "LBU":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LBU.rt=atoi(C);
LBU.offset=atoi(D);
LBU.base=atoi(E);
fwrite(LBU,4,1,fp2);
break;
case "LDC1":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LDC1.ft=atoi(C);
LDC1.offset=atoi(D);
LDC1.base=atoi(E);
fwrite(LDC1,4,1,fp2);
break;
case "LDC2":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LDC2.rt=atoi(C);
LDC2.offset=atoi(D);
LDC2.base=atoi(E);
fwrite(LDC2,4,1,fp2);
break;
case "LH":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LH.rt=atoi(C);
LH.offset=atoi(D);
LH.base=atoi(E);
fwrite(LH,4,1,fp2);
break;
case "LHU":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LHU.rt=atoi(C);
LHU.offset=atoi(D);
LHU.base=atoi(E);
fwrite(LHU,4,1,fp2);
break;
case "LL":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LL.rt=atoi(C);
LL.offset=atoi(D);
LL.base=atoi(E);
fwrite(LL,4,1,fp2);
break;
case "LW":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LW.rt=atoi(C);
LW.offset=atoi(D);
LW.base=atoi(E);
fwrite(LW,4,1,fp2);
break;
case "LWC1":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LWC1.ft=atoi(C);
LWC1.offset=atoi(D);
LWC1.base=atoi(E);
fwrite(LWC1,4,1,fp2);
break;
case "LWC2":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LWC2.rt=atoi(C);
LWC2.offset=atoi(D);
LWC2.base=atoi(E);
fwrite(LWC2,4,1,fp2);
break;
case "LWL":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LWL.rt=atoi(C);
LWL.offset=atoi(D);
LWL.base=atoi(E);
fwrite(LWL,4,1,fp2);
break;
case "LWR":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
LWR.rt=atoi(C);
LWR.offset=atoi(D);
LWR.base=atoi(E);
fwrite(LWR,4,1,fp2);
break;
case "MFC0":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MFC0.rt=atoi(C);
MFC0.rd=atoi(D);
MFC0.sel=atoi(E);
fwrite(MFC0,4,1,fp2);
break;
case "MFC2":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MFC2.rt=atoi(C);
MFC2.rd=atoi(D);
MFC2.sel=atoi(E);
fwrite(MFC2,4,1,fp2);
break;
case "MOVF":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVF.rd=atoi(C);
MOVF.rs=atoi(D);
=ato

i(E);
fwrite(MOVF,4,1,fp2);
break;
case "MOVF.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVF.S.fd=atoi(C);
MOVF.S.fs=atoi(D);
=atoi(E);
fwrite(MOVF.S,4,1,fp2);
break;
case "MOVF.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVF.D.fd=atoi(C);
MOVF.D.fs=atoi(D);
=atoi(E);
fwrite(MOVF.D,4,1,fp2);
break;
case "MOVN":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVN.rd=atoi(C);
MOVN.rs=atoi(D);
MOVN.rt=atoi(E);
fwrite(MOVN,4,1,fp2);
break;
case "MOVN.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVN.S.fd=atoi(C);
MOVN.S.fs=atoi(D);
MOVN.rt=atoi(E);
fwrite(MOVN,4,1,fp2);
break;
case "MOVT":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVT.rd=atoi(C);
MOVT.rs=atoi(D);
=atoi(E);
fwrite(MOVT,4,1,fp2);
break;
case "MOVT.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVT.S.fd=atoi(C);
MOVT.S.fs=atoi(D);
=atoi(E);
fwrite(MOVT.S,4,1,fp2);
break;
case "MOVT.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVT.D.fd=atoi(C);
MOVT.D.fs=atoi(D);
=atoi(E);
fwrite(MOVT.D,4,1,fp2);
break;
case "MOVZ":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVZ.rd=atoi(C);
MOVZ.rs=atoi(D);
MOVZ.rt=atoi(E);
fwrite(MOVZ,4,1,fp2);
break;
case "MOVZ.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVZ.S.fd=atoi(C);
MOVZ.S.fs=atoi(D);
MOVZ.S.rt=atoi(E);
fwrite(MOVZ.S,4,1,fp2);
break;
case "MOVZ.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MOVZ.D.fd=atoi(C);
MOVZ.D.fs=atoi(D);
MOVZ.D.rt=atoi(E);
fwrite(MOVZ.D,4,1,fp2);
break;
case "MTC0":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MTC0.rt=atoi(C);
MTC0.rd=atoi(D);
MTC0.sel=atoi(E);
fwrite(MTC0,4,1,fp2);
break;
case "MTC2":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MTC2.rt=atoi(C);
MTC2.rd=atoi(D);
MTC2.sel=atoi(E);
fwrite(MTC2,4,1,fp2);
break;
case "MUL":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MUL.rd=atoi(C);
MUL.rs=atoi(D);
MUL.rt=atoi(E);
fwrite(MUL,4,1,fp2);
break;
case "MUL.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MUL.S.fd=atoi(C);
MUL.S.fs=atoi(D);
MUL.Sft=atoi(E);
fwrite(MUL.S,4,1,fp2);
break;
case "MUL.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MUL.D.fd=atoi(C);
MUL.D.fs=atoi(D);
MUL.D.ft=atoi(E);
fwrite(MUL.D,4,1,fp2);
break;
case "NOR":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
NOR.rd=atoi(C);
NOR.rs=atoi(D);
NOR.rt=atoi(E);
fwrite(NOR,4,1,fp2);
break;
case "OR":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
OR.rd=atoi(C);
OR.rs=atoi(D);
OR.rt=atoi(E);
fwrite(OR,4,1,fp2);
break;
case "ORI":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ORI.rt=atoi(C);
ORI.rs=atoi(D);
ORI.imm=atoi(E);
fwrite(ORI,4,1,fp2);
break;
case "PREF":
C=strtok(B,",");
D=strtok(NULL,"

(");
E=strtok(NULL,")");
PREF.hint=atoi(C);
PREF.offset=atoi(D);
PREF.base=atoi(E);
fwrite(PREF,4,1,fp2);
break;
case "SB":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SB.rt=atoi(C);
SB.offset=atoi(D);
SB.base=atoi(E);
fwrite(SB,4,1,fp2);
break;
case "SC":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SC.rt=atoi(C);
SC.offset=atoi(D);
SC.base=atoi(E);
fwrite(SC,4,1,fp2);
break;
case "SDC1":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SDC1.ft=atoi(C);
SDC1.offset=atoi(D);
SDC1.base=atoi(E);
fwrite(SDC1,4,1,fp2);
break;
case "SDC2":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SDC2.rt=atoi(C);
SDC2.offset=atoi(D);
SDC2.base=atoi(E);
fwrite(SDC2,4,1,fp2);
break;
case "SH":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SH.rt=atoi(C);
SH.offset=atoi(D);
SH.base=atoi(E);
fwrite(SH,4,1,fp2);
break;
case "SLL":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLL.rd=atoi(C);
SLL.rt=atoi(D);
SLL.sa=atoi(E);
fwrite(SLL,4,1,fp2);
break;
case "SLLV":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLLV.rd=atoi(C);
SLLV.rt=atoi(D);
SLLV.rs=atoi(E);
fwrite(SLLV,4,1,fp2);
break;
case "SLT":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLT.rd=atoi(C);
SLT.rs=atoi(D);
SLT.rt=atoi(E);
fwrite(SLT,4,1,fp2);
break;
case "SLTI":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLTI.rt=atoi(C);
SLTI.rs=atoi(D);
SLTI.imm=atoi(E);
fwrite(SLTI,4,1,fp2);
break;
case "SLTIU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLTIU.rt=atoi(C);
SLTIU.rs=atoi(D);
SLTIU.imm=atoi(E);
fwrite(SLTIU,4,1,fp2);
break;
case "SLTU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SLTU.rd=atoi(C);
SLTU.rs=atoi(D);
SLTU.rt=atoi(E);
fwrite(SLTU,4,1,fp2);
break;
case "SRA":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SRA.rd=atoi(C);
SRA.rt=atoi(D);
SRA.sa=atoi(E);
fwrite(SRA,4,1,fp2);
break;
case "SRAV":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SRA.rd=atoi(C);
SRA.rt=atoi(D);
SRA.rs=atoi(E);
fwrite(SRA,4,1,fp2);
break;
case "SRL":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SRL.rd=atoi(C);
SRL.rt=atoi(D);
SRL.sa=atoi(E);
fwrite(SRL,4,1,fp2);
break;
case "SRLV":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SRLV.rd=atoi(C);
SRLV.rt=atoi(D);
SRLV.rs=atoi(E);
fwrite(SRLV,4,1,fp2);
break;
case "SUB":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SUB.rd=atoi(C);
SUB.rs=atoi(D);
SUB.rt=atoi(E);
fwrite(SUB,4,1,fp2);
break;
case "SUB.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SUB.S.fd=atoi(C);
SUB.S.fs=atoi(D);
SUB.S.ft=atoi(E);
fwrite(SUB.S,4,1,fp2);
break;
case "SUB.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SUB.D.fd=atoi(C);
SUB.D.fs=atoi(D);
SUB.D.ft=atoi(E);
fwrite(SUB.D,4,1,fp2);
break;
case "SUBU":
C=strtok(B,",");


D=strtok(NULL,",");
E=strtok(NULL,",");
SUBU.rd=atoi(C);
SUBU.rs=atoi(D);
SUBU.rt=atoi(E);
fwrite(SUBU,4,1,fp2);
break;
case "SW":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SW.rt=atoi(C);
SW.offset=atoi(D);
SW.base=atoi(E);
fwrite(SW,4,1,fp2);
break;
case "SWC1":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SWC1.ft=atoi(C);
SWC1.offset=atoi(D);
SWC1.base=atoi(E);
fwrite(SWC1,4,1,fp2);
break;
case "SWC2":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SWC2.rt=atoi(C);
SWC2.offset=atoi(D);
SWC2.base=atoi(E);
fwrite(SWC2,4,1,fp2);
break;
case "SWL":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SWL.rt=atoi(C);
SWL.offset=atoi(D);
SWL.base=atoi(E);
fwrite(SWL,4,1,fp2);
break;
case "SWR":
C=strtok(B,",");
D=strtok(NULL,"(");
E=strtok(NULL,")");
SWR.rt=atoi(C);
SWR.offset=atoi(D);
SWR.base=atoi(E);
fwrite(SWR,4,1,fp2);
break;
case "TEQ":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TEQ.rs=atoi(C);
TEQ.rt=atoi(D);
TEQ.code=atoi(E);
fwrite(TEQ,4,1,fp2);
break;
case "TGE":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TGE.rs=atoi(C);
TGE.rt=atoi(D);
TGE.code=atoi(E);
fwrite(TGE,4,1,fp2);
break;
case "TGEU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TGEU.rs=atoi(C);
TGEU.rt=atoi(D);
TGEU.code=atoi(E);
fwrite(TGEU,4,1,fp2);
break;
case "TLT":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TLT.rs=atoi(C);
TLT.rt=atoi(D);
TLT.code=atoi(E);
fwrite(TLT,4,1,fp2);
break;
case "TLTU":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TLTU.rs=atoi(C);
TLTU.rt=atoi(D);
TLTU.code=atoi(E);
fwrite(TLTU,4,1,fp2);
break;
case "TNE":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
TNE.rs=atoi(C);
TNE.rt=atoi(D);
TNE.code=atoi(E);
fwrite(TNE,4,1,fp2);
break;
case "XOR":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
XOR.rd=atoi(C);
XOR.rs=atoi(D);
XOR.rt=atoi(E);
fwrite(XOR,4,1,fp2);
break;
case "XORI":
C=strtok(B,",");
D=strtok(NULL,",");
D=strtok(NULL,",");
XORI.rt=atoi(C);
XORI.rs=atoi(D);
XORI.imm=atoi(E);
fwrite(XORI,4,1,fp2);
break;
case "MULTG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MULTG.rd=atoi(C);
MULTG.rs=atoi(D);
MULTG.rt=atoi(E);
fwrite(MULTG,4,1,fp2);
break;
case "MULTUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MULTUG.rd=atoi(C);
MULTUG.rs=atoi(D);
MULTUG.rt=atoi(E);
fwrite(MULTUG,4,1,fp2);
break;
case "DMULTG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DMULTG.rd=atoi(C);
DMULTG.rs=atoi(D);
DMULTG.rt=atoi(E);
fwrite(DMULTG,4,1,fp2);
break;
case "DMULTUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DMULTUG.rd=atoi(C);
DMULTUG.rs=atoi(D);
DMULTUG.rt=atoi(E);
fwrite(DMULTUG,4,1,fp2);
break;
case "DIVG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DIVG.rd=atoi(C);
DIVG.rs=atoi(D);
DIVG.rt=atoi(E);


fwrite(DIVG,4,1,fp2);
break;
case "DIVUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DIVUG.rd=atoi(C);
DIVUG.rs=atoi(D);
DIVUG.rt=atoi(E);
fwrite(DIVUG,4,1,fp2);
break;
case "DDIVG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DDIVG.rd=atoi(C);
DDIVG.rs=atoi(D);
DDIVG.rt=atoi(E);
fwrite(DDIVG,4,1,fp2);
break;
case "DDIVUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DDIVUG.rd=atoi(C);
DDIVUG.rs=atoi(D);
DDIVUG.rt=atoi(E);
fwrite(DDIVUG,4,1,fp2);
break;
case "MODG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MODG.rd=atoi(C);
MODG.rs=atoi(D);
MODG.rt=atoi(E);
fwrite(MODG,4,1,fp2);
break;
case "MODUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MODUG.rd=atoi(C);
MODUG.rs=atoi(D);
MODUG.rt=atoi(E);
fwrite(MODUG,4,1,fp2);
break;
case "DMODG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DMODG.rd=atoi(C);
DMODG.rs=atoi(D);
DMODG.rt=atoi(E);
fwrite(DMODG,4,1,fp2);
break;
case "DMODUG":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
DMODUG.rd=atoi(C);
DMODUG.rs=atoi(D);
DMODUG.rt=atoi(E);
fwrite(DMODUG,4,1,fp2);
break;
case "MADD.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MADD.S.fd=atoi(C);
MADD.S.fs=atoi(D);
MADD.S.ft=atoi(E);
fwrite(MADD.S,4,1,fp2);
break;
case "MADD.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MADD.D.fd=atoi(C);
MADD.D.fs=atoi(D);
MADD.D.ft=atoi(E);
fwrite(MADD.D,4,1,fp2);
break;
case "MSUB.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MSUB.S.fd=atoi(C);
MSUB.S.fs=atoi(D);
MSUB.S.ft=atoi(E);
fwrite(MSUB.S,4,1,fp2);
break;
case "MSUB.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MSUB.D.fd=atoi(C);
MSUB.D.fs=atoi(D);
MSUB.D.ft=atoi(E);
fwrite(MSUB.D,4,1,fp2);
break;
case "NMADD.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
NMADD.S.fd=atoi(C);
NMADD.S.fs=atoi(D);
NMADD.S.ft=atoi(E);
fwrite(NMADD.S,4,1,fp2);
break;
case "NMADD.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
NMADD.D.fd=atoi(C);
NMADD.D.fs=atoi(D);
NMADD.D.ft=atoi(E);
fwrite(NMADD.D,4,1,fp2);
break;
case "NMSUB.S":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
NMSUB.S.fd=atoi(C);
NMSUB.S.fs=atoi(D);
NMSUB.S.ft=atoi(E);
fwrite(NMSUB.S,4,1,fp2);
break;
case "NMSUB.D":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
NMSUB.D.fd=atoi(C);
NMSUB.D.fs=atoi(D);
NMSUB.D.ft=atoi(E);
fwrite(NMSUB.D,4,1,fp2);
break;
case "ADD.PS":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
ADD.PS.fd=atoi(C);
ADD.PS.fs=atoi(D);
ADD.PS.ft=atoi(E);
fwrite(ADD.PS,4,1,fp2);
break;
case "SUB.PS":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
SUB.PS.fd=atoi(C);
SUB.PS.fs=atoi(D);
SUB.PS.ft=atoi(E);
fwrite(SUB.PS,4,1,fp2);
break;
case "MUL.PS":
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
MUL

.PS.fd=atoi(C);
MUL.PS.fs=atoi(D);
MUL.PS.ft=atoi(E);
fwrite(MUL.PS,4,1,fp2);
break;
case "ABS.PS":
C=strtok(B,",");
D=strtok(NULL,",");
ABS.PS.fd=atoi(C);
ABS.PS.fs=atoi(D);
fwrite(ABS.PS,4,1,fp2);
break;
case "MOV.PS":
C=strtok(B,",");
D=strtok(NULL,",");
MOV.PS.fd=atoi(C);
MOV.PS.fs=atoi(D);
fwrite(MOV.PS,4,1,fp2);
break;
case "NGE.PS":
C=strtok(B,",");
D=strtok(NULL,",");
NGE.PS.fd=atoi(C);
NGE.PS.fs=atoi(D);
fwrite(NGE.PS,4,1,fp2);
break;
case "C.F.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.F.PS.m=atoi(C);
C.F.PS.fs=atoi(D);
C.F.PS.ft=atoi(E);
fwrite(C.F.PS,4,1,fp2);
break;
case "C.UN.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.UN.PS.m=atoi(C);
C.UN.PS.fs=atoi(D);
C.UN.PS.ft=atoi(E);
fwrite(C.UM.PS,4,1,fp2);
break;
case "C.EQ.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.EQ.PS.m=atoi(C);
C.EQ.PS.fs=atoi(D);
C.EQ.PS.ft=atoi(E);
fwrite(C.EQ.PS,4,1,fp2);
break;
case "C.UEQ.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.UEQ.PS.m=atoi(C);
C.UEQ.PS.fs=atoi(D);
C.UEQ.PS.ft=atoi(E);
fwrite(C.UEQ.PS,4,1,fp2);
break;
case "C.OLT.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.OLT.PS.m=atoi(C);
C.OLT.PS.fs=atoi(D);
C.OLT.PS.ft=atoi(E);
fwrite(C.OLT.PS,4,1,fp2);
break;
case "C.ULT.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.ULT.PS.m=atoi(C);
C.ULT.PS.fs=atoi(D);
C.ULT.PS.ft=atoi(E);
fwrite(C.ULT.PS,4,1,fp2);
break;
case "C.OLE.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.OLE.PS.m=atoi(C);
C.OLE.PS.fs=atoi(D);
C.OLE.PS.ft=atoi(E);
fwrite(C.OLE.PS,4,1,fp2);
break;
case "C.ULE.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.ULE.PS.m=atoi(C);
C.ULE.PS.fs=atoi(D);
C.ULE.PS.ft=atoi(E);
fwrite(C.ULE.PS,4,1,fp2);
break;
case "C.SF.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.SF.PS.m=atoi(C);
C.SF.PS.fs=atoi(D);
C.SF.PS.ft=atoi(E);
fwrite(C.SF.PS,4,1,fp2);
break;
case "C.NGLE.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.NGLE.PS.m=atoi(C);
C.NGLE.PS.fs=atoi(D);
C.NGLE.PS.ft=atoi(E);
fwrite(C.NGLE.PS,4,1,fp2);
break;
case "C.SEQ.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.SEQ.PS.m=atoi(C);
C.SEQ.PS.fs=atoi(D);
C.SEQ.PS.ft=atoi(E);
fwrite(C.SEQ.PS,4,1,fp2);
break;
case "C.NGL.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.NGL.PS.m=atoi(C);
C.NGL.PS.fs=atoi(D);
C.NGL.PS.ft=atoi(E);
fwrite(C.NGL.PS,4,1,fp2);
break;
case "C.LT.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.LT.PS.m=atoi(C);
C.LT.PS.fs=atoi(D);
C.LT.PS.ft=atoi(E);
fwrite(C.LT.PS,4,1,fp2);
break;
case "C.NGE.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.NGE.PS.m=atoi(C);
C.NGE.PS.fs=atoi(D);
C.NGE.PS.ft=atoi(E);
fwrite(C.NGE.PS,4,1,fp2);
break;
case "C.LE.PS"
C=strtok(B,",");
D=strtok(NULL,",");

E=strtok(NULL,",");
C.LE.PS.m=atoi(C);
C.LE.PS.fs=atoi(D);
C.LE.PS.ft=atoi(E);
fwrite(C.LE.PS,4,1,fp2);
break;
case "C.NGT.PS"
C=strtok(B,",");
D=strtok(NULL,",");
E=strtok(NULL,",");
C.NGT.PS.m=atoi(C);
C.NGT.PS.fs=atoi(D);
C.NGT.PS.ft=atoi(E);
fwrite(C.NGT.PS,4,1,fp2);
break;
default:
printf("暂不支持此指令或此格式:s%",du);
}
if((cuo=ferror(fp1))==1)
{
sprintf("文件操作出错");
exit (1);
}
while((jiewei=feof(fp1))==0)
fclose(fp1);
fclose(fp2);
}

相关文档
最新文档