6 // CPU Instruction Set (mips16)
9 // The instructions in this section are ordered according
10 // to http://www.sgi.com/MIPS/arch/MIPS16/mips16.pdf.
13 // The MIPS16 codes registers in a special way, map from one to the other.
14 // :<type>:<flags>:<models>:<typedef>:<name>:<field>:<expression>
15 :compute:::int:TRX:RX:((RX < 2) ? (16 + RX) \: RX)
16 :compute:::int:TRY:RY:((RY < 2) ? (16 + RY) \: RY)
17 :compute:::int:TRZ:RZ:((RZ < 2) ? (16 + RZ) \: RZ)
18 :compute:::int:SHIFT:SHAMT:((SHAMT == 0) ? 8 \: SHAMT)
20 :compute:::int:SHAMT:SHAMT_4_0,S5:(LSINSERTED (S5, 5, 5) | SHAMT_4_0)
22 :compute:::address_word:IMMEDIATE:IMM_25_21,IMM_20_16,IMMED_15_0:(LSINSERTED (IMM_25_21, 25, 21) | LSINSERTED (IMM_20_16, 20, 16) | LSINSERTED (IMMED_15_0, 15, 0))
23 :compute:::int:R32:R32L,R32H:((R32H << 3) | R32L)
25 :compute:::address_word:IMMEDIATE:IMM_10_5,IMM_15_11,IMM_4_0:(LSINSERTED (IMM_10_5, 10, 5) | LSINSERTED (IMM_15_11, 15, 11) | LSINSERTED (IMM_4_0, 4, 0))
27 :compute:::address_word:IMMEDIATE:IMM_10_4,IMM_14_11,IMM_3_0:(LSINSERTED (IMM_10_4, 10, 4) | LSINSERTED (IMM_14_11, 14, 11) | LSINSERTED (IMM_3_0, 3, 0))
30 // Load and Store Instructions
33 10000,3.RX,3.RY,5.IMMED:RRI:16::LB
34 "lb r<TRY>, <IMMED> (r<TRX>)"
38 GPR[TRY] = EXTEND8 (do_load (SD_, AccessLength_BYTE, GPR[TRX], IMMED));
41 11110,6.IMM_10_5,5.IMM_15_11 + 10000,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LB
42 "lb r<TRY>, <IMMEDIATE> (r<TRX>)"
46 GPR[TRY] = EXTEND8 (do_load (SD_, AccessLength_BYTE, GPR[TRX], EXTEND16 (IMMEDIATE)));
51 10100,3.RX,3.RY,5.IMMED:RRI:16::LBU
52 "lbu r<TRY>, <IMMED> (r<TRX>)"
56 GPR[TRY] = do_load (SD_, AccessLength_BYTE, GPR[TRX], IMMED);
59 11110,6.IMM_10_5,5.IMM_15_11 + 10100,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LBU
60 "lbu r<TRY>, <IMMEDIATE> (r<TRX>)"
64 GPR[TRY] = do_load (SD_, AccessLength_BYTE, GPR[TRX], EXTEND16 (IMMEDIATE));
69 10001,3.RX,3.RY,5.IMMED:RRI:16::LH
70 "lh r<TRY>, <IMMED> (r<TRX>)"
74 GPR[TRY] = EXTEND16 (do_load (SD_, AccessLength_HALFWORD, GPR[TRX], IMMED << 1));
77 11110,6.IMM_10_5,5.IMM_15_11 + 10001,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LH
78 "lh r<TRY>, <IMMEDIATE> (r<TRX>)"
82 GPR[TRY] = EXTEND16 (do_load (SD_, AccessLength_HALFWORD, GPR[TRX], EXTEND16 (IMMEDIATE)));
87 10101,3.RX,3.RY,5.IMMED:RRI:16::LHU
88 "lhu r<TRY>, <IMMED> (r<TRX>)"
92 GPR[TRY] = do_load (SD_, AccessLength_HALFWORD, GPR[TRX], IMMED << 1);
95 11110,6.IMM_10_5,5.IMM_15_11 + 10101,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LHU
96 "lhu r<TRY>, <IMMEDIATE> (r<TRX>)"
100 GPR[TRY] = do_load (SD_, AccessLength_HALFWORD, GPR[TRX], EXTEND16 (IMMEDIATE));
105 10011,3.RX,3.RY,5.IMMED:RRI:16::LW
106 "lw r<TRY>, <IMMED> (r<TRX>)"
110 GPR[TRY] = EXTEND32 (do_load (SD_, AccessLength_WORD, GPR[TRX], IMMED << 2));
113 11110,6.IMM_10_5,5.IMM_15_11 + 10011,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LW
114 "lw r<TRY>, <IMMEDIATE> (r<TRX>)"
118 GPR[TRY] = EXTEND32 (do_load (SD_, AccessLength_WORD, GPR[TRX], EXTEND16 (IMMEDIATE)));
123 10110,3.RX,8.IMMED:RI:16::LWPC
124 "lw r<TRX>, <IMMED> (PC)"
128 GPR[TRX] = EXTEND32 (do_load (SD_, AccessLength_WORD,
129 basepc (SD_) & ~3, IMMED << 2));
132 11110,6.IMM_10_5,5.IMM_15_11 + 10110,3.RX,000,5.IMM_4_0:EXT-RI:16::LWPC
133 "lw r<TRX>, <IMMEDIATE> (PC)"
137 GPR[TRX] = EXTEND32 (do_load (SD_, AccessLength_WORD, basepc (SD_) & ~3, EXTEND16 (IMMEDIATE)));
142 10010,3.RX,8.IMMED:RI:16::LWSP
143 "lw r<TRX>, <IMMED> (SP)"
147 GPR[TRX] = EXTEND32 (do_load (SD_, AccessLength_WORD, SP, IMMED << 2));
150 11110,6.IMM_10_5,5.IMM_15_11 + 10010,3.RX,000,5.IMM_4_0:EXT-RI:16::LWSP
151 "lw r<TRX>, <IMMEDIATE> (SP)"
155 GPR[TRX] = EXTEND32 (do_load (SD_, AccessLength_WORD, SP, EXTEND16 (IMMEDIATE)));
160 10111,3.RX,3.RY,5.IMMED:RRI:16::LWU
161 "lwu r<TRY>, <IMMED> (r<TRX>)"
165 GPR[TRY] = do_load (SD_, AccessLength_WORD, GPR[TRX], IMMED << 2);
168 11110,6.IMM_10_5,5.IMM_15_11 + 10111,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LWU
169 "lwu r<TRY>, <IMMEDIATE> (r<TRX>)"
173 GPR[TRY] = do_load (SD_, AccessLength_WORD, GPR[TRX], EXTEND16 (IMMEDIATE));
178 00111,3.RX,3.RY,5.IMMED:RRI:16::LD
179 "ld r<TRY>, <IMMED> (r<TRX>)"
183 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD, GPR[TRX], IMMED << 3);
186 11110,6.IMM_10_5,5.IMM_15_11 + 00111,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::LD
187 "ld r<TRY>, <IMMEDIATE> (r<TRX>)"
191 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD, GPR[TRX], EXTEND16 (IMMEDIATE));
196 11111,100,3.RY,5.IMMED:RI64:16::LDPC
197 "ld r<TRY>, <IMMED> (PC)"
201 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD,
202 basepc (SD_) & ~7, IMMED << 3);
205 11110,6.IMM_10_5,5.IMM_15_11 + 11111,100,3.RY,5.IMM_4_0:EXT-RI64:16::LDPC
206 "ld r<TRY>, <IMMEDIATE> (PC)"
210 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD, basepc (SD_) & ~7, EXTEND16 (IMMEDIATE));
215 11111,000,3.RY,5.IMMED:RI64:16::LDSP
216 "ld r<TRY>, <IMMED> (SP)"
220 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD, SP, IMMED << 3);
223 11110,6.IMM_10_5,5.IMM_15_11 + 11111,000,3.RY,5.IMM_4_0:EXT-RI64:16::LDSP
224 "ld r<TRY>, <IMMEDIATE> (SP)"
228 GPR[TRY] = do_load (SD_, AccessLength_DOUBLEWORD, SP, EXTEND16 (IMMEDIATE));
233 11000,3.RX,3.RY,5.IMMED:RRI:16::SB
234 "sb r<TRY>, <IMMED> (r<TRX>)"
238 do_store (SD_, AccessLength_BYTE, GPR[TRX], IMMED, GPR[TRY]);
241 11110,6.IMM_10_5,5.IMM_15_11 + 11000,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::SB
242 "sb r<TRY>, <IMMEDIATE> (r<TRX>)"
246 do_store (SD_, AccessLength_BYTE, GPR[TRX], EXTEND16 (IMMEDIATE), GPR[TRY]);
251 11001,3.RX,3.RY,5.IMMED:RRI:16::SH
252 "sh r<TRY>, <IMMED> (r<TRX>)"
256 do_store (SD_, AccessLength_HALFWORD, GPR[TRX], IMMED << 1, GPR[TRY]);
259 11110,6.IMM_10_5,5.IMM_15_11 + 11001,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::SH
260 "sh r<TRY>, <IMMEDIATE> (r<TRX>)"
264 do_store (SD_, AccessLength_HALFWORD, GPR[TRX], EXTEND16 (IMMEDIATE), GPR[TRY]);
269 11011,3.RX,3.RY,5.IMMED:RRI:16::SW
270 "sw r<TRY>, <IMMED> (r<TRX>)"
274 do_store (SD_, AccessLength_WORD, GPR[TRX], IMMED << 2, GPR[TRY]);
277 11110,6.IMM_10_5,5.IMM_15_11 + 11011,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::SW
278 "sw r<TRY>, <IMMEDIATE> (r<TRX>)"
282 do_store (SD_, AccessLength_WORD, GPR[TRX], EXTEND16 (IMMEDIATE), GPR[TRY]);
287 11010,3.RX,8.IMMED:RI:16::SWSP
288 "sw r<TRX>, <IMMED> (SP)"
292 do_store (SD_, AccessLength_WORD, SP, IMMED << 2, GPR[TRX]);
295 11110,6.IMM_10_5,5.IMM_15_11 + 11010,3.RX,000,5.IMM_4_0:EXT-RI:16::SWSP
296 "sw r<TRX>, <IMMEDIATE> (SP)"
300 do_store (SD_, AccessLength_WORD, SP, EXTEND16 (IMMEDIATE), GPR[TRX]);
305 01100,010,8.IMMED:I8:16::SWRASP
306 "sw r<RAIDX>, <IMMED> (SP)"
310 do_store (SD_, AccessLength_WORD, SP, IMMED << 2, RA);
313 11110,6.IMM_10_5,5.IMM_15_11 + 01100,010,000,5.IMM_4_0:EXT-I8:16::SWRASP
314 "sw r<RAIDX>, <IMMEDIATE> (SP)"
318 do_store (SD_, AccessLength_WORD, SP, EXTEND16 (IMMEDIATE), RA);
323 01111,3.RX,3.RY,5.IMMED:RRI:16::SD
324 "sd r<TRY>, <IMMED> (r<TRX>)"
328 do_store (SD_, AccessLength_DOUBLEWORD, GPR[TRX], IMMED << 3, GPR[TRY]);
331 11110,6.IMM_10_5,5.IMM_15_11 + 01111,3.RX,3.RY,5.IMM_4_0:EXT-RRI:16::SD
332 "sd r<TRY>, <IMMEDIATE> (r<TRX>)"
336 do_store (SD_, AccessLength_DOUBLEWORD, GPR[TRX], EXTEND16 (IMMEDIATE), GPR[TRY]);
341 11111,001,3.RY,5.IMMED:RI64:16::SDSP
342 "sd r<TRY>, <IMMED> (SP)"
346 do_store (SD_, AccessLength_DOUBLEWORD, SP, IMMED << 3, GPR[TRY]);
349 11110,6.IMM_10_5,5.IMM_15_11 + 11111,001,3.RY,5.IMM_4_0:EXT-RI64:16::SDSP
350 "sd r<TRY>, <IMMEDIATE> (SP)"
354 do_store (SD_, AccessLength_DOUBLEWORD, SP, EXTEND16 (IMMEDIATE), GPR[TRY]);
359 11111,010,8.IMMED:I64:16::SDRASP
360 "sd r<RAIDX>, <IMMED> (SP)"
364 do_store (SD_, AccessLength_DOUBLEWORD, SP, IMMED << 3, RA);
367 11110,6.IMM_10_5,5.IMM_15_11 + 11111,010,000,5.IMM_4_0:EXT-I64:16::SDRASP
368 "sd r<RAIDX>, <IMMEDIATE> (SP)"
372 do_store (SD_, AccessLength_DOUBLEWORD, SP, EXTEND16 (IMMEDIATE), RA);
377 // ALU Immediate Instructions
380 01101,3.RX,8.IMMED:RI:16::LI
385 do_ori (SD_, 0, TRX, IMMED);
388 11110,6.IMM_10_5,5.IMM_15_11 + 01101,3.RX,000,5.IMM_4_0:EXT-RI:16::LI
389 "li r<TRX>, <IMMEDIATE>"
393 do_ori (SD_, 0, TRX, IMMEDIATE);
398 01000,3.RX,3.RY,0,4.IMMED:RRI-A:16::ADDIU
399 "addiu r<TRY>, r<TRX>, <IMMED>"
403 do_addiu (SD_, TRX, TRY, EXTEND4 (IMMED));
406 11110,7.IMM_10_4,4.IMM_14_11 + 01000,3.RX,3.RY,0,4.IMM_3_0:EXT-RRI-A:16::ADDIU
407 "addiu r<TRY>, r<TRX>, <IMMEDIATE>"
411 do_addiu (SD_, TRX, TRY, EXTEND15 (IMMEDIATE));
416 01001,3.RX,8.IMMED:RI:16::ADDIU8
417 "addiu r<TRX>, <IMMED>"
421 do_addiu (SD_, TRX, TRX, EXTEND8 (IMMED));
424 11110,6.IMM_10_5,5.IMM_15_11 + 01001,3.RX,000,5.IMM_4_0:EXT-RI:16::ADDIU8
425 "addiu r<TRX>, <IMMEDIATE>"
429 do_addiu (SD_, TRX, TRX, EXTEND16 (IMMEDIATE));
434 01100,011,8.IMMED:I8:16::ADJSP
439 do_addiu (SD_, SPIDX, SPIDX, EXTEND8 (IMMED) << 3);
442 11110,6.IMM_10_5,5.IMM_15_11 + 01100,011,000,5.IMM_4_0:EXT-I8:16::ADJSP
443 "addiu SP, <IMMEDIATE>"
447 do_addiu (SD_, SPIDX, SPIDX, EXTEND16 (IMMEDIATE));
452 00001,3.RX,8.IMMED:RI:16::ADDIUPC
453 "addiu r<TRX>, PC, <IMMED>"
457 uint32_t temp = (basepc (SD_) & ~3) + (IMMED << 2);
458 GPR[TRX] = EXTEND32 (temp);
461 11110,6.IMM_10_5,5.IMM_15_11 + 00001,3.RX,000,5.IMM_4_0:EXT-RI:16::ADDIUPC
462 "addiu r<TRX>, PC, <IMMEDIATE>"
466 uint32_t temp = (basepc (SD_) & ~3) + EXTEND16 (IMMEDIATE);
467 GPR[TRX] = EXTEND32 (temp);
472 00000,3.RX,8.IMMED:RI:16::ADDIUSP
473 "addiu r<TRX>, SP, <IMMED>"
477 do_addiu (SD_, SPIDX, TRX, IMMED << 2);
480 11110,6.IMM_10_5,5.IMM_15_11 + 00000,3.RX,000,5.IMM_4_0:EXT-RI:16::ADDIUSP
481 "addiu r<TRX>, SP, <IMMEDIATE>"
485 do_addiu (SD_, SPIDX, TRX, EXTEND16 (IMMEDIATE));
490 01000,3.RX,3.RY,1,4.IMMED:RRI-A:16::DADDIU
491 "daddiu r<TRY>, r<TRX>, <IMMED>"
495 do_daddiu (SD_, TRX, TRY, EXTEND4 (IMMED));
498 11110,7.IMM_10_4,4.IMM_14_11 + 01000,3.RX,3.RY,1,4.IMM_3_0:EXT-RRI-A:16::DADDIU
499 "daddiu r<TRY>, r<TRX>, <IMMEDIATE>"
503 do_daddiu (SD_, TRX, TRY, EXTEND15 (IMMEDIATE));
508 11111,101,3.RY,5.IMMED:RI64:16::DADDIU5
509 "daddiu r<TRY>, <IMMED>"
513 do_daddiu (SD_, TRY, TRY, EXTEND5 (IMMED));
516 11110,6.IMM_10_5,5.IMM_15_11 + 11111,101,3.RY,5.IMM_4_0:EXT-RI64:16::DADDIU5
517 "daddiu r<TRY>, <IMMEDIATE>"
521 do_daddiu (SD_, TRY, TRY, EXTEND16 (IMMEDIATE));
526 11111,011,8.IMMED:I64:16::DADJSP
531 do_daddiu (SD_, SPIDX, SPIDX, EXTEND8 (IMMED) << 3);
534 11110,6.IMM_10_5,5.IMM_15_11 + 11111,011,000,5.IMM_4_0:EXT-I64:16::DADJSP
535 "daddiu SP, <IMMEDIATE>"
539 do_daddiu (SD_, SPIDX, SPIDX, EXTEND16 (IMMEDIATE));
544 11111,110,3.RY,5.IMMED:RI64:16::DADDIUPC
545 "daddiu r<TRY>, PC, <IMMED>"
549 GPR[TRY] = (basepc (SD_) & ~3) + (IMMED << 2);
552 11110,6.IMM_10_5,5.IMM_15_11 + 11111,110,3.RY,5.IMM_4_0:EXT-RI64:16::DADDIUPC
553 "daddiu r<TRY>, PC, <IMMEDIATE>"
557 GPR[TRY] = (basepc (SD_) & ~3) + EXTEND16 (IMMEDIATE);
562 11111,111,3.RY,5.IMMED:RI64:16::DADDIUSP
563 "daddiu r<TRY>, SP, <IMMED>"
567 do_daddiu (SD_, SPIDX, TRY, IMMED << 2);
570 11110,6.IMM_10_5,5.IMM_15_11 + 11111,111,3.RY,5.IMM_4_0:EXT-RI64:16::DADDIUSP
571 "daddiu r<TRY>, SP, <IMMEDIATE>"
575 do_daddiu (SD_, SPIDX, TRY, EXTEND16 (IMMEDIATE));
580 01010,3.RX,8.IMMED:RI:16::SLTI
581 "slti r<TRX>, <IMMED>"
585 do_slti (SD_, TRX, T8IDX, IMMED);
588 11110,6.IMM_10_5,5.IMM_15_11 + 01010,3.RX,000,5.IMM_4_0:EXT-RI:16::SLTI
589 "slti r<TRX>, <IMMEDIATE>"
593 do_slti (SD_, TRX, T8IDX, IMMEDIATE);
598 01011,3.RX,8.IMMED:RI:16::SLTIU
599 "sltiu r<TRX>, <IMMED>"
603 do_sltiu (SD_, TRX, T8IDX, IMMED);
606 11110,6.IMM_10_5,5.IMM_15_11 + 01011,3.RX,000,5.IMM_4_0:EXT-RI:16::SLTIU
607 "sltiu r<TRX>, <IMMEDIATE>"
611 do_sltiu (SD_, TRX, T8IDX, IMMEDIATE);
616 11101,3.RX,3.RY,01010:RR:16::CMP
621 do_xor (SD_, TRX, TRY, T8IDX);
625 01110,3.RX,8.IMMED:RI:16::CMPI
626 "cmpi r<TRX>, <IMMED>"
630 do_xori (SD_, TRX, T8IDX, IMMED);
633 11110,6.IMM_10_5,5.IMM_15_11 + 01110,3.RX,000,5.IMM_4_0:EXT-RI:16::CMPI
634 "sltiu r<TRX>, <IMMEDIATE>"
638 do_xori (SD_, TRX, T8IDX, IMMEDIATE);
643 // Two/Three Operand, Register-Type
647 11100,3.RX,3.RY,3.RZ,01:RRR:16::ADDU
648 "addu r<TRZ>, r<TRX>, r<TRY>"
652 do_addu (SD_, TRX, TRY, TRZ);
657 11100,3.RX,3.RY,3.RZ,11:RRR:16::SUBU
658 "subu r<TRZ>, r<TRX>, r<TRY>"
662 do_subu (SD_, TRX, TRY, TRZ);
665 11100,3.RX,3.RY,3.RZ,00:RRR:16::DADDU
666 "daddu r<TRZ>, r<TRX>, r<TRY>"
670 do_daddu (SD_, TRX, TRY, TRZ);
675 11100,3.RX,3.RY,3.RZ,10:RRR:16::DSUBU
676 "dsubu r<TRZ>, r<TRX>, r<TRY>"
680 do_dsubu (SD_, TRX, TRY, TRZ);
685 11101,3.RX,3.RY,00010:RR:16::SLT
690 do_slt (SD_, TRX, TRY, T8IDX);
695 11101,3.RX,3.RY,00011:RR:16::SLTU
696 "sltu r<TRX>, r<TRY>"
700 do_sltu (SD_, TRX, TRY, T8IDX);
705 11101,3.RX,3.RY,01011:RR:16::NEG
710 do_subu (SD_, 0, TRY, TRX);
715 11101,3.RX,3.RY,01100:RR:16::AND
720 do_and (SD_, TRX, TRY, TRX);
725 11101,3.RX,3.RY,01101:RR:16::OR
730 do_or (SD_, TRX, TRY, TRX);
735 11101,3.RX,3.RY,01110:RR:16::XOR
740 do_xor (SD_, TRX, TRY, TRX);
745 11101,3.RX,3.RY,01111:RR:16::NOT
750 do_nor (SD_, 0, TRY, TRX);
755 01100,111,3.RY,5.R32:I8_MOVR32:16::MOVR32
756 "move r<TRY>, r<R32>"
760 do_or (SD_, R32, 0, TRY);
765 01100,101,3.R32L,2.R32H,3.RZ:I8_MOV32R:16::MOV32R
766 "move r<R32>, r<TRZ>"
770 do_or (SD_, TRZ, 0, R32);
775 00110,3.RX,3.RY,3.SHAMT,00:SHIFT:16::SLL
776 "sll r<TRX>, r<TRY>, <SHIFT>"
780 do_sll (SD_, TRY, TRX, SHIFT);
783 11110,5.SHAMT,0,00000 + 00110,3.RX,3.RY,000,00:EXT-SHIFT:16::SLL
784 "sll r<TRX>, r<TRY>, <SHIFT>"
788 do_sll (SD_, TRY, TRX, SHAMT);
793 00110,3.RX,3.RY,3.SHAMT,10:SHIFT:16::SRL
794 "srl r<TRX>, r<TRY>, <SHIFT>"
798 do_srl (SD_, TRY, TRX, SHIFT);
801 11110,5.SHAMT,0,00000 + 00110,3.RX,3.RY,000,10:EXT-SHIFT:16::SRL
802 "srl r<TRX>, r<TRY>, <SHIFT>"
806 do_srl (SD_, TRY, TRX, SHAMT);
811 00110,3.RX,3.RY,3.SHAMT,11:SHIFT:16::SRA
812 "sra r<TRX>, r<TRY>, <SHIFT>"
816 do_sra (SD_, TRY, TRX, SHIFT);
819 11110,5.SHAMT,0,00000 + 00110,3.RX,3.RY,000,11:EXT-SHIFT:16::SRA
820 "sra r<TRX>, r<TRY>, <SHIFT>"
824 do_sra (SD_, TRY, TRX, SHAMT);
829 11101,3.RX,3.RY,00100:RR:16::SLLV
830 "sllv r<TRY>, r<TRX>"
834 do_sllv (SD_, TRX, TRY, TRY);
838 11101,3.RX,3.RY,00110:RR:16::SRLV
839 "srlv r<TRY>, r<TRX>"
843 do_srlv (SD_, TRX, TRY, TRY);
847 11101,3.RX,3.RY,00111:RR:16::SRAV
848 "srav r<TRY>, r<TRX>"
852 do_srav (SD_, TRX, TRY, TRY);
856 00110,3.RX,3.RY,3.SHAMT,01:SHIFT:16::DSLL
857 "dsll r<TRY>, r<TRX>, <SHIFT>"
861 do_dsll (SD_, TRY, TRX, SHIFT);
864 11110,5.SHAMT_4_0,1.S5,00000 + 00110,3.RX,3.RY,000,01:EXT-SHIFT:16::DSLL
865 "dsll r<TRY>, r<TRX>, <SHAMT>"
869 do_dsll (SD_, TRY, TRX, SHAMT);
874 11101,3.SHAMT,3.RY,01000:SHIFT64:16::DSRL
875 "dsrl r<TRY>, <SHIFT>"
879 do_dsrl (SD_, TRY, TRY, SHIFT);
882 11110,5.SHAMT_4_0,1.S5,00000 + 11101,000,3.RY,01000:EXT-SHIFT64:16::DSRL
883 "dsrl r<TRY>, <SHAMT>"
887 do_dsrl (SD_, TRY, TRY, SHAMT);
892 11101,3.SHAMT,3.RY,10011:SHIFT64:16::DSRA
893 "dsra r<TRY>, <SHIFT>"
897 do_dsra (SD_, TRY, TRY, SHIFT);
900 11110,5.SHAMT_4_0,1.S5,00000 + 11101,000,3.RY,10011:EXT-SHIFT64:16::DSRA
901 "dsra r<TRY>, <SHAMT>"
905 do_dsra (SD_, TRY, TRY, SHAMT);
910 11101,3.RX,3.RY,10100:RR:16::DSLLV
911 "dsllv r<TRY>, r<TRX>"
915 do_dsllv (SD_, TRX, TRY, TRY);
919 11101,3.RX,3.RY,10110:RR:16::DSRLV
920 "dsrlv r<TRY>, r<TRX>"
924 do_dsrlv (SD_, TRX, TRY, TRY);
928 11101,3.RX,3.RY,10111:RR:16::DSRAV
929 "dsrav r<TRY>, r<TRX>"
933 do_dsrav (SD_, TRX, TRY, TRY);
937 // Multiply /Divide Instructions
940 11101,3.RX,3.RY,11000:RR:16::MULT
941 "mult r<TRX>, r<TRY>"
945 do_mult (SD_, TRX, TRY, 0);
949 11101,3.RX,3.RY,11001:RR:16::MULTU
950 "multu r<TRX>, r<TRY>"
954 do_multu (SD_, TRX, TRY, 0);
958 11101,3.RX,3.RY,11010:RR:16::DIV
963 do_div (SD_, TRX, TRY);
967 11101,3.RX,3.RY,11011:RR:16::DIVU
968 "divu r<TRX>, r<TRY>"
972 do_divu (SD_, TRX, TRY);
976 11101,3.RX,000,10000:RR:16::MFHI
985 11101,3.RX,000,10010:RR:16::MFLO
994 11101,3.RX,3.RY,11100:RR:16::DMULT
995 "dmult r<TRX>, r<TRY>"
999 do_dmult (SD_, TRX, TRY, 0);
1003 11101,3.RX,3.RY,11101:RR:16::DMULTU
1004 "dmultu r<TRX>, r<TRY>"
1008 do_dmultu (SD_, TRX, TRY, 0);
1012 11101,3.RX,3.RY,11110:RR:16::DDIV
1013 "ddiv r<TRX>, r<TRY>"
1017 do_ddiv (SD_, TRX, TRY);
1021 11101,3.RX,3.RY,11111:RR:16::DDIVU
1022 "ddivu r<TRX>, r<TRY>"
1026 do_ddivu (SD_, TRX, TRY);
1030 // Jump and Branch Instructions
1034 // Issue instruction in delay slot of branch
1035 :function:::address_word:delayslot16:address_word nia, address_word target
1037 instruction_word delay_insn;
1038 sim_events_slip (SD, 1);
1039 DSPC = CIA; /* save current PC somewhere */
1040 STATE |= simDELAYSLOT;
1041 delay_insn = IMEM16 (nia); /* NOTE: mips16 */
1042 idecode_issue (CPU_, delay_insn, (nia));
1043 STATE &= ~simDELAYSLOT;
1047 // compute basepc dependant on us being in a delay slot
1048 :function:::address_word:basepc:
1050 if (STATE & simDELAYSLOT)
1052 return DSPC; /* return saved address of preceeding jmp */
1062 00011,0,5.IMM_20_16,5.IMM_25_21 + 16.IMMED_15_0:JAL:16::JAL
1067 address_word region = (NIA & MASK (63, 28));
1068 RA = NIA + 2; /* skip 16 bit delayslot insn */
1069 NIA = delayslot16 (SD_, NIA, (region | (IMMEDIATE << 2))) | 1;
1074 // JALX - 32 and 16 bit versions.
1076 011101,26.IMMED:JALX:32::JALX32
1085 address_word region = (NIA & MASK (63, 28));
1086 RA = NIA + 4; /* skip 32 bit delayslot insn */
1087 NIA = delayslot32 (SD_, (region | (IMMED << 2)) | 1);
1090 00011,1,5.IMM_20_16,5.IMM_25_21 + 16.IMMED_15_0:JALX:16::JALX16
1095 address_word region = (NIA & MASK (63, 28));
1096 RA = NIA + 2; /* 16 bit INSN */
1097 NIA = delayslot16 (SD_, NIA, (region | (IMMEDIATE << 2)) & ~1);
1102 11101,3.RX,000,00000:RR:16::JR
1107 NIA = delayslot16 (SD_, NIA, GPR[TRX]);
1111 11101,000,001,00000:RR:16::JRRA
1116 NIA = delayslot16 (SD_, NIA, RA);
1121 11101,3.RX,010,00000:RR:16::JALR
1127 NIA = delayslot16 (SD_, NIA, GPR[TRX]);
1132 00100,3.RX,8.IMMED:RI:16::BEQZ
1133 "beqz r<TRX>, <IMMED>"
1138 NIA = (NIA + (EXTEND8 (IMMED) << 1));
1141 11110,6.IMM_10_5,5.IMM_15_11 + 00100,3.RX,000,5.IMM_4_0:EXT-RI:16::BEQZ
1142 "beqz r<TRX>, <IMMEDIATE>"
1147 NIA = (NIA + (EXTEND16 (IMMEDIATE) << 1));
1152 00101,3.RX,8.IMMED:RI:16::BNEZ
1153 "bnez r<TRX>, <IMMED>"
1158 NIA = (NIA + (EXTEND8 (IMMED) << 1));
1161 11110,6.IMM_10_5,5.IMM_15_11 + 00101,3.RX,000,5.IMM_4_0:EXT-RI:16::BNEZ
1162 "bnez r<TRX>, <IMMEDIATE>"
1167 NIA = (NIA + (EXTEND16 (IMMEDIATE) << 1));
1172 01100,000,8.IMMED:I8:16::BTEQZ
1178 NIA = (NIA + (EXTEND8 (IMMED) << 1));
1181 11110,6.IMM_10_5,5.IMM_15_11 + 01100,000,000,5.IMM_4_0:EXT-I8:16::BTEQZ
1187 NIA = (NIA + (EXTEND16 (IMMEDIATE) << 1));
1192 01100,001,8.IMMED:I8:16::BTNEZ
1198 NIA = (NIA + (EXTEND8 (IMMED) << 1));
1201 11110,6.IMM_10_5,5.IMM_15_11 + 01100,001,000,5.IMM_4_0:EXT-I8:16::BTNEZ
1207 NIA = (NIA + (EXTEND16 (IMMEDIATE) << 1));
1212 00010,11.IMMED:I:16::B
1217 NIA = (NIA + (EXTEND11 (IMMED) << 1));
1220 11110,6.IMM_10_5,5.IMM_15_11 + 00010,6.0,5.IMM_4_0:EXT-I:16::B
1225 NIA = (NIA + (EXTEND16 (IMMEDIATE) << 1));
1230 11101,3.RX,3.RY,00101:RR:16::BREAK
1235 do_break16 (SD_, instruction_0);