[2] | 1 | /*
|
---|
| 2 | * File: MOperator.h
|
---|
| 3 | * Author: rick
|
---|
| 4 | *
|
---|
| 5 | * Created on November 19, 2008, 1:24 AM
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef _MOPERATOR_H
|
---|
| 9 | #define _MOPERATOR_H
|
---|
| 10 |
|
---|
| 11 | /* Needs including all available instruction types */
|
---|
| 12 | typedef enum __moperator {
|
---|
| 13 | /* ASM directives */
|
---|
| 14 | MOP_ENT,
|
---|
| 15 | MOP_END,
|
---|
| 16 | MOP_ALIGN,
|
---|
| 17 | MOP_ASCII,
|
---|
| 18 | MOP_ASCIIZ,
|
---|
| 19 | MOP_BYTE,
|
---|
| 20 | MOP_DATA,
|
---|
| 21 | MOP_DOUBLE,
|
---|
| 22 | MOP_EXTERN,
|
---|
| 23 | MOP_FLOAT,
|
---|
| 24 | MOP_GLOBL,
|
---|
| 25 | MOP_HALF,
|
---|
| 26 | MOP_KDATA,
|
---|
| 27 | MOP_KTEXT,
|
---|
| 28 | MOP_SPACE,
|
---|
| 29 | MOP_TEXT,
|
---|
| 30 | MOP_WORD,
|
---|
| 31 |
|
---|
| 32 | /* Arithmetic operators */
|
---|
| 33 |
|
---|
| 34 | /* Absolute value - abs Rdest, Rsrc
|
---|
| 35 | Put the absolute value of the integer from register Rsrc in register Rdest. */
|
---|
| 36 | MOP_ABS,
|
---|
| 37 | /* Addition with overflow - add Rdest, Rsrc1, Src2
|
---|
| 38 | Addition Immediate with overflow - addi Rdest, Rsrc1, Imm
|
---|
| 39 | Addition with overflow - add Rdest, Rsrc1, Src2
|
---|
| 40 | Addition Immediate without overflow - addi Rdest, Rsrc1, Imm
|
---|
| 41 | Put the sum of the integers from register Rscr1 and Src2 (or Imm) into register Rdest. */
|
---|
| 42 | MOP_ADD,
|
---|
| 43 | MOP_ADDI,
|
---|
| 44 | MOP_ADDU,
|
---|
| 45 | MOP_ADDIU,
|
---|
| 46 | /* and - and Rdest, Rsrc1, Src2
|
---|
| 47 | and immediate - andi Rdest, Rsrc1, Imm
|
---|
| 48 | Put the logical AND of the integers from register Rscr1and Sr2( or Imm) into register Rdest. */
|
---|
| 49 | MOP_AND,
|
---|
| 50 | MOP_ANDI,
|
---|
| 51 | /* Divide signed - div Rsrc1, Rscr2
|
---|
| 52 | Divide unsigned - divu Rscr1, Rscr2
|
---|
| 53 | Divide the contents of the two registers. Leave quotient in register lo and the remainder in register hi. */
|
---|
| 54 | MOP_DIV2,
|
---|
| 55 | MOP_DIV2U,
|
---|
| 56 | /* Divide signed - div Rdest, Rsrc1, Rscr2
|
---|
| 57 | Divide unsigned - divu Rdest, Rscr1, Rscr2
|
---|
| 58 | Divide the contents of the two registers. Leave quotient in register Rdest. */
|
---|
| 59 | MOP_DIV,
|
---|
| 60 | MOP_DIVU,
|
---|
| 61 | /* Multiply without overflow - mul Rdest, Rsrc1, Rsrc2
|
---|
| 62 | Multiply with overflow - mulo Rdest, Rsrc1, Rsrc2
|
---|
| 63 | Unsigned multiply with overflow - mulou Rdest, Rsrc1, Rsrc2
|
---|
| 64 | Put the product of the integers from register Rscr1 and Rscr2 into register Rdest. */
|
---|
| 65 | MOP_MUL,
|
---|
| 66 | MOP_MULO,
|
---|
| 67 | MOP_MULOU,
|
---|
| 68 | /* Multiply - mult Rsrc1, Rsrc2
|
---|
| 69 | Unsigned multiply - multu Rsrc1, Rsrc2
|
---|
| 70 | Multiply the contents of the two registers. Leave the low-order word of the product in register lo an the high-word in register hi. */
|
---|
| 71 | MOP_MULT,
|
---|
| 72 | MOP_MULTU,
|
---|
| 73 | /* Negate value with overflow - neg Rdest, Rsrc
|
---|
| 74 | Negate value without overflow - negu Rdest, Rsrc
|
---|
| 75 | Put the negative of the integer from register Rsrc into Rdest. */
|
---|
| 76 | MOP_NEG,
|
---|
| 77 | MOP_NEGU,
|
---|
| 78 | /* NOR - nor Rdest, Rsrc1, Rsrc2
|
---|
| 79 | Put the logical NOR of the integers from register Rsrc1 and Rscr2 into register Rdes. */
|
---|
| 80 | MOP_NOR,
|
---|
| 81 | /* NOT - not Rdest, Rsrc
|
---|
| 82 | Put the bitwise logical negation of the integer from register Rscr into register Rdest. */
|
---|
| 83 | MOP_NOT,
|
---|
| 84 | /* OR - or Rdest, Rsrc1, Rsrc2
|
---|
| 85 | OR Immediate - ori Rdest, Rsrc1, Imm
|
---|
| 86 | Put the logical OR of the integer from registe rRsrc1 and Rsrc2(or Imm) into register Rdest. */
|
---|
| 87 | MOP_OR,
|
---|
| 88 | MOP_ORI,
|
---|
| 89 | /* Remainder - rem Rdest, Rsrc1, Rsrc2
|
---|
| 90 | Unsigned remainder - remu Rdest, Rsrc1, Rsrc2
|
---|
| 91 | Put the remainder from dividing Rsrc1 with the integer Rsrc2 into Rdest.
|
---|
| 92 | If an operand is negative the remainder is unspecified. */
|
---|
| 93 | MOP_REM,
|
---|
| 94 | MOP_REMU,
|
---|
| 95 | /* Rotate left - rol Rdest, Rscr1, Src2
|
---|
| 96 | Rotate right - ror Rdest, Rsrc1, Src2
|
---|
| 97 | Rotate the contents of register Rsrc by the distance indicated by Src2 and store in Rdest. */
|
---|
| 98 | MOP_ROL,
|
---|
| 99 | MOP_ROR,
|
---|
| 100 | /* Shift left logical - sll Rdest, Rsrc1, Src2
|
---|
| 101 | Shift left logical variable - sllv Rdest, Rsrc1, Rsrc2
|
---|
| 102 | Shift right arithmetic - sra Rdest, Rsrc1, src2
|
---|
| 103 | Shift right logical - srl Rdest, Rsrc1, src2
|
---|
| 104 | Shift right variable - srlv Rdest, Rsrc1, Rsrc2
|
---|
| 105 | Shift the contents of Rsrc1 by the distance in Src2 and put the result in Rdest. */
|
---|
| 106 | MOP_SLL,
|
---|
| 107 | MOP_SLLV,
|
---|
| 108 | MOP_SRA,
|
---|
| 109 | MOP_SRL,
|
---|
| 110 | MOP_SRLV,
|
---|
| 111 | /* Subtract with overflow - sub Rdest Rsrc, Src2
|
---|
| 112 | Subtract without overflow - subu Rdest, Rsrc, Src2
|
---|
| 113 | Put the difference of the integers from register Rssrc1 and Src2 into Rdest */
|
---|
| 114 | MOP_SUB,
|
---|
| 115 | MOP_SUBU,
|
---|
| 116 | /* XOR - xor Rdest, Rsrc1, Src2
|
---|
| 117 | XOR immediate - xori Rdest, Rsrc1, Imm
|
---|
| 118 | Put the logiacal xor of the integer from register Rscr1 and Src2 (or Imm) into register Rdest. */
|
---|
| 119 | MOP_XOR,
|
---|
| 120 | MOP_XORI,
|
---|
| 121 | /* Load immediate - li Rdest, imm
|
---|
| 122 | Move the immediate imm into register Rdest. */
|
---|
| 123 | MOP_LI,
|
---|
| 124 | /* Load upper immediate -lui Rdest, imm
|
---|
| 125 | Load the lower halfword of the immediate imm into the upper halfword of register Rdest . The lower bits of the resgister are set to 0. */
|
---|
| 126 | MOP_LUI,
|
---|
| 127 |
|
---|
| 128 | /* Comparison operators */
|
---|
| 129 | /* Set equal - seq Rdest, Rsrc1, Src2
|
---|
| 130 | Set register Rdest to 1 if register Rsrc1 equals Src2 and to 0 otherwise. */
|
---|
| 131 | MOP_SEQ,
|
---|
| 132 | MOP_SGE,
|
---|
| 133 | MOP_SGEU,
|
---|
| 134 | MOP_SGT,
|
---|
| 135 | MOP_SGTU,
|
---|
| 136 | MOP_SLE,
|
---|
| 137 | MOP_SLEU,
|
---|
| 138 | MOP_SLT,
|
---|
| 139 | MOP_SLTI,
|
---|
| 140 | MOP_SLTU,
|
---|
| 141 | MOP_SLTIU,
|
---|
| 142 | MOP_SNE,
|
---|
| 143 |
|
---|
| 144 | /* Branching operators */
|
---|
| 145 | MOP_B,
|
---|
| 146 | MOP_BCZT,
|
---|
| 147 | MOP_BCZF,
|
---|
| 148 | MOP_BEQ,
|
---|
| 149 | MOP_BEQZ,
|
---|
| 150 | MOP_BGE,
|
---|
| 151 | MOP_BGEU,
|
---|
| 152 | MOP_BGEZ,
|
---|
| 153 | MOP_BGEZAL,
|
---|
| 154 | MOP_BGT,
|
---|
| 155 | MOP_BGTU,
|
---|
| 156 | MOP_BGTZ,
|
---|
| 157 | MOP_BLE,
|
---|
| 158 | MOP_BLEU,
|
---|
| 159 | MOP_BLEZ,
|
---|
| 160 | MOP_BLTZAL,
|
---|
| 161 | MOP_BLT,
|
---|
| 162 | MOP_BLTU,
|
---|
| 163 | MOP_BLTZ,
|
---|
| 164 | MOP_BNE,
|
---|
| 165 | MOP_BNEZ,
|
---|
| 166 |
|
---|
| 167 | /* Jump operators */
|
---|
| 168 | MOP_J,
|
---|
| 169 | MOP_JAL,
|
---|
| 170 | MOP_JR,
|
---|
| 171 |
|
---|
| 172 | /* Load operators */
|
---|
| 173 | MOP_LA,
|
---|
| 174 | MOP_LB,
|
---|
| 175 | MOP_LBU,
|
---|
| 176 | MOP_LD,
|
---|
| 177 | MOP_LH,
|
---|
| 178 | MOP_LHU,
|
---|
| 179 | MOP_LW,
|
---|
| 180 | MOP_LWCZ,
|
---|
| 181 | MOP_LWL,
|
---|
| 182 | MOP_LWR,
|
---|
| 183 | MOP_ULH,
|
---|
| 184 | MOP_ULHU,
|
---|
| 185 | MOP_ULW,
|
---|
| 186 |
|
---|
| 187 | /* Store operators */
|
---|
| 188 | MOP_SB,
|
---|
| 189 | MOP_SD,
|
---|
| 190 | MOP_SH,
|
---|
| 191 | MOP_SW,
|
---|
| 192 | MOP_SWCZ,
|
---|
| 193 | MOP_SWL,
|
---|
| 194 | MOP_SWR,
|
---|
| 195 | MOP_USH,
|
---|
| 196 | MOP_USW,
|
---|
| 197 |
|
---|
| 198 | /* Copy operators */
|
---|
| 199 | MOP_MOVE,
|
---|
| 200 | MOP_MFHI,
|
---|
| 201 | MOP_MTLO,
|
---|
| 202 | MOP_MFC1,
|
---|
| 203 | MOP_MFC1_D,
|
---|
| 204 | MOP_MTC1,
|
---|
| 205 |
|
---|
| 206 | /* Floating point operators */
|
---|
| 207 | MOP_ABS_D,
|
---|
| 208 | MOP_ABS_S,
|
---|
| 209 | MOP_ADD_D,
|
---|
| 210 | MOP_ADD_S,
|
---|
| 211 | MOP_C_EQ_D,
|
---|
| 212 | MOP_C_EQ_S,
|
---|
| 213 | MOP_C_LE_D,
|
---|
| 214 | MOP_C_LE_S,
|
---|
| 215 | MOP_C_LT_D,
|
---|
| 216 | MOP_C_LT_S,
|
---|
| 217 | MOP_CVT_D_S,
|
---|
| 218 | MOP_CVT_D_W,
|
---|
| 219 | MOP_CVT_S_D,
|
---|
| 220 | MOP_CVT_S_W,
|
---|
| 221 | MOP_CVT_W_D,
|
---|
| 222 | MOP_CVT_W_S,
|
---|
| 223 | MOP_DIV_D,
|
---|
| 224 | MOP_DIV_S,
|
---|
| 225 | MOP_L_D,
|
---|
| 226 | MOP_L_S,
|
---|
| 227 | MOP_MOV_D,
|
---|
| 228 | MOP_MOV_S,
|
---|
| 229 | MOP_MUL_D,
|
---|
| 230 | MOP_MUL_S,
|
---|
| 231 | MOP_NEG_D,
|
---|
| 232 | MOP_NEG_S,
|
---|
| 233 | MOP_S_D,
|
---|
| 234 | MOP_S_S,
|
---|
| 235 | MOP_SUB_D,
|
---|
| 236 | MOP_SUB_S,
|
---|
| 237 | /* Hidden features, pseudo instructions ;-) */
|
---|
| 238 | MOP_LI_S,
|
---|
| 239 |
|
---|
| 240 | /* Exceptions and trap instructions */
|
---|
| 241 | MOP_RFE,
|
---|
| 242 | MOP_SYSCALL,
|
---|
| 243 | MOP_BREAK,
|
---|
| 244 | MOP_NOP,
|
---|
| 245 |
|
---|
| 246 | /* Special labels, for processing only */
|
---|
| 247 | MOP_LABEL,
|
---|
| 248 | MOP_NOPERATORS
|
---|
| 249 | } MOperator;
|
---|
| 250 |
|
---|
| 251 |
|
---|
| 252 | const char *MOperatorToString(MOperator op);
|
---|
| 253 |
|
---|
| 254 |
|
---|
| 255 | #endif /* _MOPERATOR_H */
|
---|
| 256 |
|
---|