00001
00002
00003
00004
00005
00006
00007 #include "copyright.h"
00008 #include "instr.h"
00009 #include "encode.h"
00010
00011 #define NULL 0
00012
00013 int sptr;
00014 int longdis = 1;
00015
00016 extern char *normalops[], *specialops[];
00017
00018
00019 char *regstrings[] =
00020 {
00021 "0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
00022 "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
00023 "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", "gp", "sp",
00024 "r30", "r31"
00025 };
00026
00027 #define R(i) regstrings[i]
00028
00029
00030 dump_ascii(instruction, pc)
00031 int instruction, pc;
00032 {
00033 int addr;
00034 char *s;
00035 int opcode;
00036
00037 if ( longdis ) printf("%08x: %08x ", pc, instruction);
00038 printf("\t");
00039 opcode = (unsigned) instruction >> 26;
00040 if ( instruction == I_NOP) {
00041 printf("nop");
00042 }
00043 else if ( opcode == I_SPECIAL )
00044 {
00045 opcode = instruction & 0x3f;
00046 printf("%s\t", specialops[opcode]);
00047
00048 switch( opcode )
00049 {
00050
00051
00052 case I_SLL:
00053 case I_SRL:
00054 case I_SRA:
00055 printf("%s,%s,0x%x",
00056 R(rd(instruction)),
00057 R(rt(instruction)),
00058 shamt(instruction));
00059 break;
00060
00061
00062 case I_SLLV:
00063 case I_SRLV:
00064 case I_SRAV:
00065 printf("%s,%s,%s",
00066 R(rd(instruction)),
00067 R(rt(instruction)),
00068 R(rs(instruction)));
00069 break;
00070
00071
00072 case I_JR:
00073 case I_JALR:
00074 case I_MFLO:
00075 case I_MTLO:
00076 printf("%s", R(rs(instruction)));
00077 break;
00078
00079 case I_SYSCALL:
00080 case I_BREAK:
00081 break;
00082
00083
00084 case I_MFHI:
00085 case I_MTHI:
00086 printf("%s", R(rd(instruction)));
00087 break;
00088
00089
00090 case I_MULT:
00091 case I_MULTU:
00092 case I_DIV:
00093 case I_DIVU:
00094 printf("%s,%s",
00095 R(rs(instruction)),
00096 R(rt(instruction)));
00097 break;
00098
00099
00100 case I_ADD:
00101 case I_ADDU:
00102 case I_SUB:
00103 case I_SUBU:
00104 case I_AND:
00105 case I_OR:
00106 case I_XOR:
00107 case I_NOR:
00108 case I_SLT:
00109 case I_SLTU:
00110 printf("%s,%s,%s",
00111 R(rd(instruction)),
00112 R(rs(instruction)),
00113 R(rt(instruction)));
00114 break;
00115
00116 }
00117 }
00118 else if ( opcode == I_BCOND )
00119 {
00120 switch ( rt(instruction) )
00121 {
00122 case I_BLTZ:
00123 printf("bltz");
00124 break;
00125 case I_BGEZ:
00126 printf("bgez");
00127 break;
00128 case I_BLTZAL:
00129 printf("bltzal");
00130 break;
00131 case I_BGEZAL:
00132 printf("bgezal");
00133 break;
00134 default :
00135 printf("BCOND");
00136 }
00137 printf("\t%s,%08x",
00138 R(rs(instruction)),
00139 off16(instruction)+pc+4);
00140 }
00141 else
00142 {
00143 printf("%s\t", normalops[opcode]);
00144
00145 switch ( opcode )
00146 {
00147
00148 case I_J:
00149 case I_JAL:
00150 printf("%08x",
00151 top4(pc)|off26(instruction));
00152 break;
00153
00154
00155 case I_BEQ:
00156 case I_BNE:
00157 printf("%s,%s,%08x",
00158 R(rt(instruction)),
00159 R(rs(instruction)),
00160 off16(instruction)+pc+4);
00161 break;
00162
00163
00164 case I_ADDI:
00165 case I_ADDIU:
00166 case I_SLTI:
00167 case I_SLTIU:
00168 case I_ANDI:
00169 case I_ORI:
00170 case I_XORI:
00171 printf("%s,%s,0x%x",
00172 R(rt(instruction)),
00173 R(rs(instruction)),
00174 immed(instruction));
00175 break;
00176
00177
00178 case I_LUI:
00179 printf("%s,0x%x",
00180 R(rt(instruction)),
00181 immed(instruction));
00182 break;
00183
00184
00185 case I_COP0:
00186 case I_COP1:
00187 case I_COP2:
00188 case I_COP3:
00189 break;
00190
00191
00192 case I_LB:
00193 case I_LH:
00194 case I_LWL:
00195 case I_LW:
00196 case I_LBU:
00197 case I_LHU:
00198 case I_LWR:
00199 case I_SB:
00200 case I_SH:
00201 case I_SWL:
00202 case I_SW:
00203 case I_SWR:
00204 case I_LWC0:
00205 case I_LWC1:
00206 case I_LWC2:
00207 case I_LWC3 :
00208 case I_SWC0:
00209 case I_SWC1:
00210 case I_SWC2:
00211 case I_SWC3:
00212 printf("%s,0x%x(%s)",
00213 R(rt(instruction)),
00214 immed(instruction),
00215 R(rs(instruction)));
00216 break;
00217 }
00218 }
00219 }
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees