4 // CPU Instruction Set (mips16)
7 // The instructions in this section are ordered according
8 // to http://www.sgi.com/MIPS/arch/MIPS16/mips16.pdf.
11 // FIXME: Instead of having the code for mips16 instructions here.
12 // these instructions should instead call the corresponding 32bit
13 // instruction (or a function implementing that instructions code).
16 // Load and Store Instructions
19 10000,xxx,ddd,55555:RRI:16::LB
22 unsigned32 instruction = instruction_0;
23 signed_word op1 = (instruction >> 8) & 0x7;
24 int destreg = (instruction >> 5) & 0x7;
25 int offset = (instruction >> 0) & 0x1f;
33 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
42 SignalException (ReservedInstruction, instruction);
44 address_word vaddr = ((unsigned64)op1 + offset);
48 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
50 unsigned64 memval = 0;
51 unsigned64 memval1 = 0;
52 unsigned64 mask = 0x7;
53 unsigned int shift = 0;
54 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
55 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
57 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
58 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
59 byte = ((vaddr & mask) ^ (bigend << shift));
60 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x000000FF),8));
67 10100,xxx,ddd,55555:RRI:16::LBU
70 unsigned32 instruction = instruction_0;
71 signed_word op1 = (instruction >> 8) & 0x7;
72 int destreg = (instruction >> 5) & 0x7;
73 int offset = (instruction >> 0) & 0x1f;
81 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
90 SignalException (ReservedInstruction, instruction);
92 address_word vaddr = ((unsigned64)op1 + offset);
96 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
98 unsigned64 memval = 0;
99 unsigned64 memval1 = 0;
100 unsigned64 mask = 0x7;
101 unsigned int shift = 0;
102 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
103 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
105 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
106 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
107 byte = ((vaddr & mask) ^ (bigend << shift));
108 GPR[destreg] = (((memval >> (8 * byte)) & 0x000000FF));
115 10001,xxx,ddd,HHHHH:RRI:16::LH
118 unsigned32 instruction = instruction_0;
119 signed_word op1 = (instruction >> 8) & 0x7;
120 int destreg = (instruction >> 5) & 0x7;
121 int offset = (instruction >> 0) & 0x1f;
129 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
130 if (offset >= 0x8000)
139 SignalException (ReservedInstruction, instruction);
141 address_word vaddr = ((unsigned64)op1 + offset);
144 if ((vaddr & 1) != 0)
145 SignalExceptionAddressLoad();
148 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
150 unsigned64 memval = 0;
151 unsigned64 memval1 = 0;
152 unsigned64 mask = 0x7;
153 unsigned int shift = 1;
154 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
155 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
157 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
158 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
159 byte = ((vaddr & mask) ^ (bigend << shift));
160 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x0000FFFF),16));
167 10101,xxx,ddd,HHHHH:RRI:16::LHU
170 unsigned32 instruction = instruction_0;
171 signed_word op1 = (instruction >> 8) & 0x7;
172 int destreg = (instruction >> 5) & 0x7;
173 int offset = (instruction >> 0) & 0x1f;
181 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
182 if (offset >= 0x8000)
191 SignalException (ReservedInstruction, instruction);
193 address_word vaddr = ((unsigned64)op1 + offset);
196 if ((vaddr & 1) != 0)
197 SignalExceptionAddressLoad();
200 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
202 unsigned64 memval = 0;
203 unsigned64 memval1 = 0;
204 unsigned64 mask = 0x7;
205 unsigned int shift = 1;
206 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
207 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
209 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
210 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
211 byte = ((vaddr & mask) ^ (bigend << shift));
212 GPR[destreg] = (((memval >> (8 * byte)) & 0x0000FFFF));
219 10011,xxx,ddd,WWWWW:RRI:16::LW
222 unsigned32 instruction = instruction_0;
223 signed_word op1 = (instruction >> 8) & 0x7;
224 int destreg = (instruction >> 5) & 0x7;
225 int offset = (instruction >> 0) & 0x1f;
233 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
234 if (offset >= 0x8000)
243 SignalException (ReservedInstruction, instruction);
245 address_word vaddr = ((unsigned64)op1 + offset);
248 if ((vaddr & 3) != 0)
249 SignalExceptionAddressLoad();
252 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
254 unsigned64 memval = 0;
255 unsigned64 memval1 = 0;
256 unsigned64 mask = 0x7;
257 unsigned int shift = 2;
258 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
259 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
261 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
262 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
263 byte = ((vaddr & mask) ^ (bigend << shift));
264 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
271 10110,ddd,VVVVVVVV,P:RI:16::LWPC
274 unsigned32 instruction = instruction_0;
275 int destreg = (instruction >> 8) & 0x7;
276 int offset = (instruction >> 0) & 0xff;
277 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
282 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
283 if (offset >= 0x8000)
292 SignalException (ReservedInstruction, instruction);
294 address_word vaddr = ((unsigned64)op1 + offset);
297 if ((vaddr & 3) != 0)
298 SignalExceptionAddressLoad();
301 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
303 unsigned64 memval = 0;
304 unsigned64 memval1 = 0;
305 unsigned64 mask = 0x7;
306 unsigned int shift = 2;
307 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
308 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
310 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
311 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
312 byte = ((vaddr & mask) ^ (bigend << shift));
313 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
320 10010,ddd,VVVVVVVV,s:RI:16::LWSP
323 unsigned32 instruction = instruction_0;
324 int destreg = (instruction >> 8) & 0x7;
325 int offset = (instruction >> 0) & 0xff;
326 signed_word op1 = 29;
331 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
332 if (offset >= 0x8000)
342 SignalException (ReservedInstruction, instruction);
344 address_word vaddr = ((unsigned64)op1 + offset);
347 if ((vaddr & 3) != 0)
348 SignalExceptionAddressLoad();
351 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
353 unsigned64 memval = 0;
354 unsigned64 memval1 = 0;
355 unsigned64 mask = 0x7;
356 unsigned int shift = 2;
357 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
358 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
360 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
361 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
362 byte = ((vaddr & mask) ^ (bigend << shift));
363 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
370 10111,xxx,ddd,WWWWW:RRI:16::LWU
373 unsigned32 instruction = instruction_0;
374 signed_word op1 = (instruction >> 8) & 0x7;
375 int destreg = (instruction >> 5) & 0x7;
376 int offset = (instruction >> 0) & 0x1f;
384 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
385 if (offset >= 0x8000)
394 SignalException (ReservedInstruction, instruction);
396 address_word vaddr = ((unsigned64)op1 + offset);
399 if ((vaddr & 3) != 0)
400 SignalExceptionAddressLoad();
403 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
405 unsigned64 memval = 0;
406 unsigned64 memval1 = 0;
407 unsigned64 mask = 0x7;
408 unsigned int shift = 2;
409 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
410 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
412 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
413 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
414 byte = ((vaddr & mask) ^ (bigend << shift));
415 GPR[destreg] = (((memval >> (8 * byte)) & 0xFFFFFFFF));
422 00111,xxx,ddd,DDDDD:RRI:16::LD
425 unsigned32 instruction = instruction_0;
426 signed_word op1 = (instruction >> 8) & 0x7;
427 int destreg = (instruction >> 5) & 0x7;
428 int offset = (instruction >> 0) & 0x1f;
436 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
437 if (offset >= 0x8000)
446 SignalException (ReservedInstruction, instruction);
448 address_word vaddr = ((unsigned64)op1 + offset);
451 if ((vaddr & 7) != 0)
452 SignalExceptionAddressLoad();
455 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
457 unsigned64 memval = 0;
458 unsigned64 memval1 = 0;
459 unsigned64 mask = 0x7;
460 unsigned int shift = 4;
461 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
462 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
464 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
465 GPR[destreg] = memval;
472 11111100,ddd,5.RD,P:RI64:16::LDPC
475 unsigned32 instruction = instruction_0;
476 int destreg = (instruction >> 5) & 0x7;
477 int offset = (instruction >> 0) & 0x1f;
478 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x7;
483 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
484 if (offset >= 0x8000)
493 SignalException (ReservedInstruction, instruction);
495 address_word vaddr = ((unsigned64)op1 + offset);
498 if ((vaddr & 7) != 0)
499 SignalExceptionAddressLoad();
502 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
504 unsigned64 memval = 0;
505 unsigned64 memval1 = 0;
506 unsigned64 mask = 0x7;
507 unsigned int shift = 4;
508 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
509 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
511 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
512 GPR[destreg] = memval;
519 11111000,ddd,5.RD,s:RI64:16::LDSP
522 unsigned32 instruction = instruction_0;
523 int destreg = (instruction >> 5) & 0x7;
524 int offset = (instruction >> 0) & 0x1f;
525 signed_word op1 = 29;
530 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
531 if (offset >= 0x8000)
541 SignalException (ReservedInstruction, instruction);
543 address_word vaddr = ((unsigned64)op1 + offset);
546 if ((vaddr & 7) != 0)
547 SignalExceptionAddressLoad();
550 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
552 unsigned64 memval = 0;
553 unsigned64 memval1 = 0;
554 unsigned64 mask = 0x7;
555 unsigned int shift = 4;
556 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
557 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
559 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
560 GPR[destreg] = memval;
567 11000,xxx,yyy,55555:RRI:16::SB
570 unsigned32 instruction = instruction_0;
571 signed_word op1 = (instruction >> 8) & 0x7;
572 signed_word op2 = (instruction >> 5) & 0x7;
573 int offset = (instruction >> 0) & 0x1f;
582 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
583 if (offset >= 0x8000)
591 SignalException (ReservedInstruction, instruction);
593 address_word vaddr = ((unsigned64)op1 + offset);
597 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
599 unsigned64 memval = 0;
600 unsigned64 memval1 = 0;
601 unsigned64 mask = 0x7;
602 unsigned int shift = 0;
603 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
604 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
606 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
607 byte = ((vaddr & mask) ^ (bigend << shift));
608 memval = ((unsigned64) op2 << (8 * byte));
610 StoreMemory(uncached,AccessLength_BYTE,memval,memval1,paddr,vaddr,isREAL);
618 11001,xxx,yyy,HHHHH:RRI:16::SH
621 unsigned32 instruction = instruction_0;
622 signed_word op1 = (instruction >> 8) & 0x7;
623 signed_word op2 = (instruction >> 5) & 0x7;
624 int offset = (instruction >> 0) & 0x1f;
633 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
634 if (offset >= 0x8000)
643 SignalException (ReservedInstruction, instruction);
645 address_word vaddr = ((unsigned64)op1 + offset);
648 if ((vaddr & 1) != 0)
649 SignalExceptionAddressStore();
652 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
654 unsigned64 memval = 0;
655 unsigned64 memval1 = 0;
656 unsigned64 mask = 0x7;
657 unsigned int shift = 1;
658 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
659 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
661 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
662 byte = ((vaddr & mask) ^ (bigend << shift));
663 memval = ((unsigned64) op2 << (8 * byte));
665 StoreMemory(uncached,AccessLength_HALFWORD,memval,memval1,paddr,vaddr,isREAL);
673 11011,xxx,yyy,WWWWW:RRI:16::SW
676 unsigned32 instruction = instruction_0;
677 signed_word op1 = (instruction >> 8) & 0x7;
678 signed_word op2 = (instruction >> 5) & 0x7;
679 int offset = (instruction >> 0) & 0x1f;
688 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
689 if (offset >= 0x8000)
698 SignalException (ReservedInstruction, instruction);
700 address_word vaddr = ((unsigned64)op1 + offset);
703 if ((vaddr & 3) != 0)
704 SignalExceptionAddressStore();
707 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
709 unsigned64 memval = 0;
710 unsigned64 memval1 = 0;
711 unsigned64 mask = 0x7;
713 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
714 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
715 memval = ((unsigned64) op2 << (8 * byte));
717 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
725 11010,yyy,VVVVVVVV,s:RI:16::SWSP
728 unsigned32 instruction = instruction_0;
729 signed_word op2 = (instruction >> 8) & 0x7;
730 int offset = (instruction >> 0) & 0xff;
731 signed_word op1 = 29;
737 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
738 if (offset >= 0x8000)
748 SignalException (ReservedInstruction, instruction);
750 address_word vaddr = ((unsigned64)op1 + offset);
753 if ((vaddr & 3) != 0)
754 SignalExceptionAddressStore();
757 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
759 unsigned64 memval = 0;
760 unsigned64 memval1 = 0;
761 unsigned64 mask = 0x7;
763 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
764 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
765 memval = ((unsigned64) op2 << (8 * byte));
767 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
775 01100010,VVVVVVVV,Q,s:I8:16::SWRASP
778 unsigned32 instruction = instruction_0;
779 int offset = (instruction >> 0) & 0xff;
780 signed_word op2 = 31;
781 signed_word op1 = 29;
784 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
785 if (offset >= 0x8000)
796 SignalException (ReservedInstruction, instruction);
798 address_word vaddr = ((unsigned64)op1 + offset);
801 if ((vaddr & 3) != 0)
802 SignalExceptionAddressStore();
805 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
807 unsigned64 memval = 0;
808 unsigned64 memval1 = 0;
809 unsigned64 mask = 0x7;
811 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
812 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
813 memval = ((unsigned64) op2 << (8 * byte));
815 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
823 01111,xxx,yyy,DDDDD:RRI:16::SD
826 unsigned32 instruction = instruction_0;
827 signed_word op1 = (instruction >> 8) & 0x7;
828 signed_word op2 = (instruction >> 5) & 0x7;
829 int offset = (instruction >> 0) & 0x1f;
838 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
839 if (offset >= 0x8000)
848 SignalException (ReservedInstruction, instruction);
850 address_word vaddr = ((unsigned64)op1 + offset);
853 if ((vaddr & 7) != 0)
854 SignalExceptionAddressStore();
857 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
859 unsigned64 memval = 0;
860 unsigned64 memval1 = 0;
863 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
871 11111001,yyy,5.RD,s:RI64:16::SDSP
874 unsigned32 instruction = instruction_0;
875 signed_word op2 = (instruction >> 5) & 0x7;
876 int offset = (instruction >> 0) & 0x1f;
877 signed_word op1 = 29;
883 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
884 if (offset >= 0x8000)
894 SignalException (ReservedInstruction, instruction);
896 address_word vaddr = ((unsigned64)op1 + offset);
899 if ((vaddr & 7) != 0)
900 SignalExceptionAddressStore();
903 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
905 unsigned64 memval = 0;
906 unsigned64 memval1 = 0;
909 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
917 11111010,CCCCCCCC,s,Q:I64:16::SDRASP
920 unsigned32 instruction = instruction_0;
921 int offset = (instruction >> 0) & 0xff;
922 signed_word op1 = 29;
923 signed_word op2 = 31;
926 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
927 if (offset >= 0x8000)
938 SignalException (ReservedInstruction, instruction);
940 address_word vaddr = ((unsigned64)op1 + offset);
943 if ((vaddr & 7) != 0)
944 SignalExceptionAddressStore();
947 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
949 unsigned64 memval = 0;
950 unsigned64 memval1 = 0;
953 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
961 // ALU Immediate Instructions
964 01101,ddd,UUUUUUUU,Z:RI:16::LI
967 unsigned32 instruction = instruction_0;
968 int destreg = (instruction >> 8) & 0x7;
969 int op2 = (instruction >> 0) & 0xff;
975 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
982 SignalException (ReservedInstruction, instruction);
985 GPR[destreg] = (op1 | op2);
990 01000,xxx,ddd,04444:RRI_A:16::ADDIU
993 unsigned32 instruction = instruction_0;
994 signed_word op1 = (instruction >> 8) & 0x7;
995 int destreg = (instruction >> 5) & 0x7;
996 int op2 = (instruction >> 0) & 0xf;
1004 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
1015 SignalException (ReservedInstruction, instruction);
1017 unsigned int temp = (unsigned int)(op1 + op2);
1018 signed int tempS = (signed int)temp;
1019 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1024 01001,www,kkkkkkkk:RI:16::ADDIU8
1027 unsigned32 instruction = instruction_0;
1028 signed_word op1 = (instruction >> 8) & 0x7;
1030 int op2 = (instruction >> 0) & 0xff;
1037 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1048 SignalException (ReservedInstruction, instruction);
1050 unsigned int temp = (unsigned int)(op1 + op2);
1051 signed int tempS = (signed int)temp;
1052 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1057 01100011,KKKKKKKK,S:I8:16::ADJSP
1060 unsigned32 instruction = instruction_0;
1061 int op2 = (instruction >> 0) & 0xff;
1062 signed_word op1 = 29;
1066 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1080 SignalException (ReservedInstruction, instruction);
1082 unsigned int temp = (unsigned int)(op1 + op2);
1083 signed int tempS = (signed int)temp;
1084 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1089 00001,ddd,AAAAAAAA,P:RI:16::ADDIUPC
1092 unsigned32 instruction = instruction_0;
1093 int destreg = (instruction >> 8) & 0x7;
1094 int op2 = (instruction >> 0) & 0xff;
1095 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
1100 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1110 SignalException (ReservedInstruction, instruction);
1112 unsigned int temp = (unsigned int)(op1 + op2);
1113 signed int tempS = (signed int)temp;
1114 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1119 00000,ddd,AAAAAAAA,s:RI:16::ADDIUSP
1122 unsigned32 instruction = instruction_0;
1123 int destreg = (instruction >> 8) & 0x7;
1124 int op2 = (instruction >> 0) & 0xff;
1125 signed_word op1 = 29;
1130 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1141 SignalException (ReservedInstruction, instruction);
1143 unsigned int temp = (unsigned int)(op1 + op2);
1144 signed int tempS = (signed int)temp;
1145 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1150 01000,xxx,ddd,14444:RRI_A:16::DADDIU
1153 unsigned32 instruction = instruction_0;
1154 signed_word op1 = (instruction >> 8) & 0x7;
1155 int destreg = (instruction >> 5) & 0x7;
1156 int op2 = (instruction >> 0) & 0xf;
1164 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
1175 SignalException (ReservedInstruction, instruction);
1177 unsigned64 temp = (unsigned64)(op1 + op2);
1178 word64 tempS = (word64)temp;
1179 GPR[destreg] = (unsigned64)temp;
1184 11111101,www,jjjjj:RI64:16::DADDIU5
1187 unsigned32 instruction = instruction_0;
1188 signed_word op1 = (instruction >> 5) & 0x7;
1190 int op2 = (instruction >> 0) & 0x1f;
1197 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1208 SignalException (ReservedInstruction, instruction);
1210 unsigned64 temp = (unsigned64)(op1 + op2);
1211 word64 tempS = (word64)temp;
1212 GPR[destreg] = (unsigned64)temp;
1217 11111011,KKKKKKKK,S:I64:16::DADJSP
1220 unsigned32 instruction = instruction_0;
1221 int op2 = (instruction >> 0) & 0xff;
1222 signed_word op1 = 29;
1226 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1240 SignalException (ReservedInstruction, instruction);
1242 unsigned64 temp = (unsigned64)(op1 + op2);
1243 word64 tempS = (word64)temp;
1244 GPR[destreg] = (unsigned64)temp;
1249 11111110,ddd,EEEEE,P:RI64:16::DADDIUPC
1252 unsigned32 instruction = instruction_0;
1253 int destreg = (instruction >> 5) & 0x7;
1254 int op2 = (instruction >> 0) & 0x1f;
1255 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
1260 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1270 SignalException (ReservedInstruction, instruction);
1272 unsigned64 temp = (unsigned64)(op1 + op2);
1273 word64 tempS = (word64)temp;
1274 GPR[destreg] = (unsigned64)temp;
1279 11111111,ddd,EEEEE,s:RI64:16::DADDIUSP
1282 unsigned32 instruction = instruction_0;
1283 int destreg = (instruction >> 5) & 0x7;
1284 int op2 = (instruction >> 0) & 0x1f;
1285 signed_word op1 = 29;
1290 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1301 SignalException (ReservedInstruction, instruction);
1303 unsigned64 temp = (unsigned64)(op1 + op2);
1304 word64 tempS = (word64)temp;
1305 GPR[destreg] = (unsigned64)temp;
1310 01010,xxx,88888888,T:RI:16::SLTI
1313 unsigned32 instruction = instruction_0;
1314 signed_word op1 = (instruction >> 8) & 0x7;
1315 int op2 = (instruction >> 0) & 0xff;
1322 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1331 SignalException (ReservedInstruction, instruction);
1333 if ((word64)op1 < (word64)op2)
1341 01011,xxx,88888888,T:RI:16::SLTIU
1344 unsigned32 instruction = instruction_0;
1345 signed_word op1 = (instruction >> 8) & 0x7;
1346 int op2 = (instruction >> 0) & 0xff;
1353 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1362 SignalException (ReservedInstruction, instruction);
1364 if ((unsigned64)op1 < (unsigned64)op2)
1372 11101,xxx,yyy,01010,T:RR:16::CMP
1375 unsigned32 instruction = instruction_0;
1376 signed_word op1 = (instruction >> 8) & 0x7;
1377 signed_word op2 = (instruction >> 5) & 0x7;
1386 SignalException (ReservedInstruction, instruction);
1388 GPR[destreg] = (op1 ^ op2);
1393 01110,xxx,UUUUUUUU,T:RI:16::CMPI
1396 unsigned32 instruction = instruction_0;
1397 signed_word op1 = (instruction >> 8) & 0x7;
1398 int op2 = (instruction >> 0) & 0xff;
1405 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
1412 SignalException (ReservedInstruction, instruction);
1414 GPR[destreg] = (op1 ^ op2);
1419 // Two/Three Operand, Register-Type
1422 11100,xxx,yyy,ddd,01:RRR:16::ADDU
1425 unsigned32 instruction = instruction_0;
1426 signed_word op1 = (instruction >> 8) & 0x7;
1427 signed_word op2 = (instruction >> 5) & 0x7;
1428 int destreg = (instruction >> 2) & 0x7;
1438 SignalException (ReservedInstruction, instruction);
1440 unsigned int temp = (unsigned int)(op1 + op2);
1441 signed int tempS = (signed int)temp;
1442 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1447 11100,xxx,yyy,ddd,11:RRR:16::SUBU
1450 unsigned32 instruction = instruction_0;
1451 signed_word op1 = (instruction >> 8) & 0x7;
1452 signed_word op2 = (instruction >> 5) & 0x7;
1453 int destreg = (instruction >> 2) & 0x7;
1463 SignalException (ReservedInstruction, instruction);
1465 unsigned int temp = (unsigned int)(op1 - op2);
1466 signed int tempS = (signed int)temp;
1467 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1472 11100,xxx,yyy,ddd,00:RRR:16::DADDU
1475 unsigned32 instruction = instruction_0;
1476 signed_word op1 = (instruction >> 8) & 0x7;
1477 signed_word op2 = (instruction >> 5) & 0x7;
1478 int destreg = (instruction >> 2) & 0x7;
1488 SignalException (ReservedInstruction, instruction);
1490 unsigned64 temp = (unsigned64)(op1 + op2);
1491 word64 tempS = (word64)temp;
1492 GPR[destreg] = (unsigned64)temp;
1497 11100,xxx,yyy,ddd,10:RRR:16::DSUBU
1500 unsigned32 instruction = instruction_0;
1501 signed_word op1 = (instruction >> 8) & 0x7;
1502 signed_word op2 = (instruction >> 5) & 0x7;
1503 int destreg = (instruction >> 2) & 0x7;
1513 SignalException (ReservedInstruction, instruction);
1515 unsigned64 temp = (unsigned64)(op1 - op2);
1516 word64 tempS = (word64)temp;
1517 GPR[destreg] = (unsigned64)temp;
1522 11101,xxx,yyy,00010,T:RR:16::SLT
1525 unsigned32 instruction = instruction_0;
1526 signed_word op1 = (instruction >> 8) & 0x7;
1527 signed_word op2 = (instruction >> 5) & 0x7;
1536 SignalException (ReservedInstruction, instruction);
1538 if ((word64)op1 < (word64)op2)
1546 11101,xxx,yyy,00011,T:RR:16::SLTU
1549 unsigned32 instruction = instruction_0;
1550 signed_word op1 = (instruction >> 8) & 0x7;
1551 signed_word op2 = (instruction >> 5) & 0x7;
1560 SignalException (ReservedInstruction, instruction);
1562 if ((unsigned64)op1 < (unsigned64)op2)
1570 11101,ddd,yyy,01011,Z:RR:16::NEG
1573 unsigned32 instruction = instruction_0;
1574 int destreg = (instruction >> 8) & 0x7;
1575 signed_word op2 = (instruction >> 5) & 0x7;
1576 signed_word op1 = 0;
1583 SignalException (ReservedInstruction, instruction);
1585 unsigned int temp = (unsigned int)(op1 - op2);
1586 signed int tempS = (signed int)temp;
1587 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
1592 11101,www,yyy,01100:RR:16::AND
1595 unsigned32 instruction = instruction_0;
1596 signed_word op1 = (instruction >> 8) & 0x7;
1598 signed_word op2 = (instruction >> 5) & 0x7;
1607 SignalException (ReservedInstruction, instruction);
1609 GPR[destreg] = (op1 & op2);
1614 11101,www,yyy,01101:RR:16::OR
1617 unsigned32 instruction = instruction_0;
1618 signed_word op1 = (instruction >> 8) & 0x7;
1620 signed_word op2 = (instruction >> 5) & 0x7;
1629 SignalException (ReservedInstruction, instruction);
1632 GPR[destreg] = (op1 | op2);
1637 11101,www,yyy,01110:RR:16::XOR
1640 unsigned32 instruction = instruction_0;
1641 signed_word op1 = (instruction >> 8) & 0x7;
1643 signed_word op2 = (instruction >> 5) & 0x7;
1652 SignalException (ReservedInstruction, instruction);
1654 GPR[destreg] = (op1 ^ op2);
1659 11101,ddd,yyy,01111,Z:RR:16::NOT
1662 unsigned32 instruction = instruction_0;
1663 int destreg = (instruction >> 8) & 0x7;
1664 signed_word op2 = (instruction >> 5) & 0x7;
1665 signed_word op1 = 0;
1672 SignalException (ReservedInstruction, instruction);
1675 GPR[destreg] = ~(op1 | op2);
1680 01100111,ddd,XXXXX,z:I8_MOVR32:16::MOVR32
1683 unsigned32 instruction = instruction_0;
1684 int destreg = (instruction >> 5) & 0x7;
1685 signed_word op1 = (instruction >> 0) & 0x1f;
1686 signed_word op2 = 0;
1691 SignalException (ReservedInstruction, instruction);
1694 GPR[destreg] = (op1 | op2);
1699 01100101,YYYYY,xxx,z:I8_MOV32R:16::MOV32R
1702 unsigned32 instruction = instruction_0;
1703 int destreg = (instruction >> 3) & 0x1f;
1704 signed_word op1 = (instruction >> 0) & 0x7;
1705 signed_word op2 = 0;
1706 destreg = (destreg >> 2) | ((destreg & 3) << 3);
1711 SignalException (ReservedInstruction, instruction);
1714 GPR[destreg] = (op1 | op2);
1719 00110,ddd,yyy,sss,00:ISHIFT:16::SLL
1722 unsigned32 instruction = instruction_0;
1723 int destreg = (instruction >> 8) & 0x7;
1724 signed_word op2 = (instruction >> 5) & 0x7;
1725 int op1 = (instruction >> 2) & 0x7;
1733 op1 = (extendval >> 6) & 0x1f;
1742 SignalException (ReservedInstruction, instruction);
1744 GPR[destreg] = ((unsigned64)op2 << op1);
1745 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1750 00110,ddd,yyy,sss,10:ISHIFT:16::SRL
1753 unsigned32 instruction = instruction_0;
1754 int destreg = (instruction >> 8) & 0x7;
1755 signed_word op2 = (instruction >> 5) & 0x7;
1756 int op1 = (instruction >> 2) & 0x7;
1764 op1 = (extendval >> 6) & 0x1f;
1773 SignalException (ReservedInstruction, instruction);
1775 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
1776 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1781 00110,ddd,yyy,sss,11:ISHIFT:16::SRA
1784 unsigned32 instruction = instruction_0;
1785 int destreg = (instruction >> 8) & 0x7;
1786 signed_word op2 = (instruction >> 5) & 0x7;
1787 int op1 = (instruction >> 2) & 0x7;
1795 op1 = (extendval >> 6) & 0x1f;
1804 SignalException (ReservedInstruction, instruction);
1806 unsigned int highbit = (unsigned int)1 << 31;
1807 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
1808 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
1809 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1814 11101,xxx,vvv,00100:RR:16::SLLV
1817 unsigned32 instruction = instruction_0;
1818 signed_word op1 = (instruction >> 8) & 0x7;
1819 signed_word op2 = (instruction >> 5) & 0x7;
1829 SignalException (ReservedInstruction, instruction);
1832 GPR[destreg] = ((unsigned64)op2 << op1);
1833 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1838 11101,xxx,vvv,00110:RR:16::SRLV
1841 unsigned32 instruction = instruction_0;
1842 signed_word op1 = (instruction >> 8) & 0x7;
1843 signed_word op2 = (instruction >> 5) & 0x7;
1853 SignalException (ReservedInstruction, instruction);
1856 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
1857 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1862 11101,xxx,vvv,00111:RR:16::SRAV
1865 unsigned32 instruction = instruction_0;
1866 signed_word op1 = (instruction >> 8) & 0x7;
1867 signed_word op2 = (instruction >> 5) & 0x7;
1877 SignalException (ReservedInstruction, instruction);
1879 unsigned int highbit = (unsigned int)1 << 31;
1881 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
1882 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
1883 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1888 00110,ddd,yyy,[[[,01:ISHIFT:16::DSLL
1891 unsigned32 instruction = instruction_0;
1892 int destreg = (instruction >> 8) & 0x7;
1893 signed_word op2 = (instruction >> 5) & 0x7;
1894 int op1 = (instruction >> 2) & 0x7;
1902 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
1911 SignalException (ReservedInstruction, instruction);
1913 GPR[destreg] = ((unsigned64)op2 << op1);
1918 11101,XXX,vvv,01000:RR:16::DSRL
1921 unsigned32 instruction = instruction_0;
1922 int op1 = (instruction >> 8) & 0x7;
1923 signed_word op2 = (instruction >> 5) & 0x7;
1927 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
1940 SignalException (ReservedInstruction, instruction);
1942 GPR[destreg] = ((unsigned64)(op2) >> op1);
1947 11101,xxx,vvv,10011:RR:16::DSRA
1950 unsigned32 instruction = instruction_0;
1951 int op1 = (instruction >> 8) & 0x7;
1952 signed_word op2 = (instruction >> 5) & 0x7;
1956 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
1969 SignalException (ReservedInstruction, instruction);
1971 unsigned64 highbit = (unsigned64)1 << 63;
1972 GPR[destreg] = ((unsigned64)(op2) >> op1);
1973 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
1978 11101,xxx,vvv,10100:RR:16::DSLLV
1981 unsigned32 instruction = instruction_0;
1982 signed_word op1 = (instruction >> 8) & 0x7;
1983 signed_word op2 = (instruction >> 5) & 0x7;
1993 SignalException (ReservedInstruction, instruction);
1996 GPR[destreg] = ((unsigned64)op2 << op1);
2001 11101,xxx,vvv,10110:RR:16::DSRLV
2004 unsigned32 instruction = instruction_0;
2005 signed_word op1 = (instruction >> 8) & 0x7;
2006 signed_word op2 = (instruction >> 5) & 0x7;
2016 SignalException (ReservedInstruction, instruction);
2019 GPR[destreg] = ((unsigned64)(op2) >> op1);
2024 11101,xxx,vvv,10111:RR:16::DSRAV
2027 unsigned32 instruction = instruction_0;
2028 signed_word op1 = (instruction >> 8) & 0x7;
2029 signed_word op2 = (instruction >> 5) & 0x7;
2039 SignalException (ReservedInstruction, instruction);
2041 unsigned64 highbit = (unsigned64)1 << 63;
2043 GPR[destreg] = ((unsigned64)(op2) >> op1);
2044 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
2049 // Multiply /Divide Instructions
2052 11101,xxx,yyy,11000:RR:16::MULT
2055 unsigned32 instruction = instruction_0;
2056 signed_word op1 = (instruction >> 8) & 0x7;
2057 signed_word op2 = (instruction >> 5) & 0x7;
2065 SignalException (ReservedInstruction, instruction);
2067 CHECKHILO("Multiplication");
2069 unsigned64 temp = ((word64) op1 * (word64) op2);
2070 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
2071 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
2077 11101,xxx,yyy,11001:RR:16::MULTU
2080 unsigned32 instruction = instruction_0;
2081 signed_word op1 = (instruction >> 8) & 0x7;
2082 signed_word op2 = (instruction >> 5) & 0x7;
2090 SignalException (ReservedInstruction, instruction);
2092 CHECKHILO("Multiplication");
2094 unsigned64 temp = ((unsigned64)(op1 & 0xffffffff) * (unsigned64)(op2 & 0xffffffff));
2095 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
2096 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
2102 11101,xxx,yyy,11010:RR:16::DIV
2105 unsigned32 instruction = instruction_0;
2106 signed_word op1 = (instruction >> 8) & 0x7;
2107 signed_word op2 = (instruction >> 5) & 0x7;
2115 SignalException (ReservedInstruction, instruction);
2117 CHECKHILO("Division");
2123 LO = SIGNEXTEND(0x80000000,32);
2124 HI = SIGNEXTEND(0,32);
2126 else if (d2 == -1 && d1 == 0x80000000)
2128 LO = SIGNEXTEND(0x80000000,32);
2129 HI = SIGNEXTEND(0,32);
2133 LO = SIGNEXTEND((d1 / d2),32);
2134 HI = SIGNEXTEND((d1 % d2),32);
2141 11101,xxx,yyy,11011:RR:16::DIVU
2144 unsigned32 instruction = instruction_0;
2145 signed_word op1 = (instruction >> 8) & 0x7;
2146 signed_word op2 = (instruction >> 5) & 0x7;
2154 SignalException (ReservedInstruction, instruction);
2156 CHECKHILO("Division");
2158 unsigned int d1 = op1;
2159 unsigned int d2 = op2;
2162 LO = SIGNEXTEND(0x80000000,32);
2163 HI = SIGNEXTEND(0,32);
2165 else if (d2 == -1 && d1 == 0x80000000)
2167 LO = SIGNEXTEND(0x80000000,32);
2168 HI = SIGNEXTEND(0,32);
2172 LO = SIGNEXTEND((d1 / d2),32);
2173 HI = SIGNEXTEND((d1 % d2),32);
2180 11101,ddd,00010000:RR:16::MFHI
2183 unsigned32 instruction = instruction_0;
2184 int destreg = (instruction >> 8) & 0x7;
2188 SignalException (ReservedInstruction, instruction);
2191 HIACCESS = 3; /* 3rd instruction will be safe */
2196 11101,ddd,00010010:RR:16::MFLO
2199 unsigned32 instruction = instruction_0;
2200 int destreg = (instruction >> 8) & 0x7;
2204 SignalException (ReservedInstruction, instruction);
2207 LOACCESS = 3; /* 3rd instruction will be safe */
2212 11101,xxx,yyy,11100:RR:16::DMULT
2215 unsigned32 instruction = instruction_0;
2216 signed_word op1 = (instruction >> 8) & 0x7;
2217 signed_word op2 = (instruction >> 5) & 0x7;
2225 SignalException (ReservedInstruction, instruction);
2227 CHECKHILO("Multiplication");
2233 if (op1 < 0) { op1 = - op1; ++sign; }
2234 if (op2 < 0) { op2 = - op2; ++sign; }
2235 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
2236 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
2237 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
2238 midhi = SET64HI(VL4_8(mid));
2239 temp = (LO + midhi);
2240 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
2243 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
2244 midhi = SET64HI(VL4_8(mid));
2245 LO = (temp + midhi);
2246 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
2249 if (sign & 1) { LO = - LO; HI = (LO == 0 ? 0 : -1) - HI; }
2255 11101,xxx,yyy,11101:RR:16::DMULTU
2258 unsigned32 instruction = instruction_0;
2259 signed_word op1 = (instruction >> 8) & 0x7;
2260 signed_word op2 = (instruction >> 5) & 0x7;
2268 SignalException (ReservedInstruction, instruction);
2270 CHECKHILO("Multiplication");
2275 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
2276 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
2277 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
2278 midhi = SET64HI(VL4_8(mid));
2279 temp = (LO + midhi);
2280 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
2283 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
2284 midhi = SET64HI(VL4_8(mid));
2285 LO = (temp + midhi);
2286 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
2294 11101,xxx,yyy,11110:RR:16::DDIV
2297 unsigned32 instruction = instruction_0;
2298 signed_word op1 = (instruction >> 8) & 0x7;
2299 signed_word op2 = (instruction >> 5) & 0x7;
2307 SignalException (ReservedInstruction, instruction);
2309 CHECKHILO("Division");
2315 LO = SIGNED64 (0x8000000000000000);
2318 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
2320 LO = SIGNED64 (0x8000000000000000);
2333 11101,xxx,yyy,11111:RR:16::DDIVU
2336 unsigned32 instruction = instruction_0;
2337 signed_word op1 = (instruction >> 8) & 0x7;
2338 signed_word op2 = (instruction >> 5) & 0x7;
2346 SignalException (ReservedInstruction, instruction);
2348 CHECKHILO("Division");
2350 unsigned64 d1 = op1;
2351 unsigned64 d2 = op2;
2354 LO = SIGNED64 (0x8000000000000000);
2357 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
2359 LO = SIGNED64 (0x8000000000000000);
2372 // Jump and Branch Instructions
2377 00011,aaaaaaaaaaa:I:16::JAL
2380 unsigned32 instruction = instruction_0;
2381 unsigned_word op1 = (instruction >> 0) & 0x7ff;
2385 if (AddressTranslation (PC &~ (unsigned64) 1, isINSTRUCTION, isLOAD, &paddr, &uncached, isTARGET, isREAL))
2388 unsigned int reverse = (ReverseEndian ? 3 : 0);
2389 unsigned int bigend = (BigEndianCPU ? 3 : 0);
2391 paddr = ((paddr & ~0x7) | ((paddr & 0x7) ^ (reverse << 1)));
2392 LoadMemory (&memval,0,uncached, AccessLength_HALFWORD, paddr, PC, isINSTRUCTION, isREAL);
2393 byte = (((PC &~ (unsigned64) 1) & 0x7) ^ (bigend << 1));
2394 memval = (memval >> (8 * byte)) & 0xffff;
2395 op1 = (((op1 & 0x1f) << 23)
2396 | ((op1 & 0x3e0) << 13)
2398 if ((instruction & 0x400) == 0)
2403 op1 |= PC & ~ (unsigned64) 0x0fffffff;
2405 SignalException (ReservedInstruction, instruction);
2408 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
2409 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
2410 so we just truncate it to 32 bits here. */
2412 /* NOTE: The jump occurs AFTER the next instruction has been executed */
2419 11101,xxx,00000000:RR:16::JR
2422 unsigned32 instruction = instruction_0;
2423 signed_word op1 = (instruction >> 8) & 0x7;
2428 SignalException (ReservedInstruction, instruction);
2430 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
2431 so we just truncate it to 32 bits here. */
2433 /* NOTE: The jump occurs AFTER the next instruction has been executed */
2440 1110100000100000,r:RR:16::JRRA
2443 unsigned32 instruction = instruction_0;
2444 signed_word op1 = 31;
2447 SignalException (ReservedInstruction, instruction);
2449 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
2450 so we just truncate it to 32 bits here. */
2452 /* NOTE: The jump occurs AFTER the next instruction has been executed */
2459 11101,xxx,01000000,R:RR:16::JALR
2462 unsigned32 instruction = instruction_0;
2463 signed_word op1 = (instruction >> 8) & 0x7;
2469 SignalException (ReservedInstruction, instruction);
2471 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
2472 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
2473 so we just truncate it to 32 bits here. */
2475 /* NOTE: The jump occurs AFTER the next instruction has been executed */
2482 00100,xxx,pppppppp,z:RI:16::BEQZ
2485 unsigned32 instruction = instruction_0;
2486 signed_word op1 = (instruction >> 8) & 0x7;
2487 int offset = (instruction >> 0) & 0xff;
2488 signed_word op2 = 0;
2494 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
2495 if (offset >= 0x8000)
2506 SignalException (ReservedInstruction, instruction);
2508 int condition = (op1 == op2);
2515 00101,xxx,pppppppp,z:RI:16::BNEZ
2518 unsigned32 instruction = instruction_0;
2519 signed_word op1 = (instruction >> 8) & 0x7;
2520 int offset = (instruction >> 0) & 0xff;
2521 signed_word op2 = 0;
2527 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
2528 if (offset >= 0x8000)
2539 SignalException (ReservedInstruction, instruction);
2541 int condition = (op1 != op2);
2548 01100000,pppppppp,t,z:I8:16::BTEQZ
2551 unsigned32 instruction = instruction_0;
2552 int offset = (instruction >> 0) & 0xff;
2553 signed_word op1 = 24;
2554 signed_word op2 = 0;
2557 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
2558 if (offset >= 0x8000)
2570 SignalException (ReservedInstruction, instruction);
2572 int condition = (op1 == op2);
2579 01100001,pppppppp,t,z:I8:16::BTNEZ
2582 unsigned32 instruction = instruction_0;
2583 int offset = (instruction >> 0) & 0xff;
2584 signed_word op1 = 24;
2585 signed_word op2 = 0;
2588 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
2589 if (offset >= 0x8000)
2601 SignalException (ReservedInstruction, instruction);
2603 int condition = (op1 != op2);
2610 00010,qqqqqqqqqqq,z,Z:I:16::B
2613 unsigned32 instruction = instruction_0;
2614 int offset = (instruction >> 0) & 0x7ff;
2615 signed_word op2 = 0;
2616 signed_word op1 = 0;
2619 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
2620 if (offset >= 0x8000)
2626 if (offset >= 0x400)
2631 SignalException (ReservedInstruction, instruction);
2633 int condition = (op1 == op2);
2640 // Special Instructions
2643 // See the front of the mips16 doc
2644 11110,eeeeeeeeeee:I:16::EXTEND
2647 unsigned32 instruction = instruction_0;
2648 int ext = (instruction >> 0) & 0x7ff;
2650 SignalException (ReservedInstruction, instruction);
2658 01100,******,00101:RR:16::BREAK
2661 unsigned32 instruction = instruction_0;
2663 SignalException (ReservedInstruction, instruction);
2665 SignalException(BreakPoint,instruction);