1 :option:::insn-bit-size:8
2 :option:::insn-specifying-widths:true
4 :model:::mn10300:mn10300:
6 // What do we do with an illegal instruction?
9 sim_io_eprintf (SD, "Illegal instruction at address 0x%lx\n",
11 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
14 // 1000 DnDn imm8....; mov imm8,Dn (imm8 is sign extended)
15 // 1000 DmDn; mov Dm,Dn (Dm != Dn, see above when Dm == Dn)
16 4.0x8,2.DM1,2.DN0:S0:::mov
24 signed32 immed = EXTEND8 (IMEM8_IMMED (cia, 1));
26 State.regs[REG_D0+DN0] = immed;
31 State.regs[REG_D0+DN0] = State.regs[REG_D0+DM1];
36 // 1111 0001 1110 DmAn; mov Dm,An
37 8.0xf1+1110,2.DM1,2.AN0:D0:::mov
43 State.regs[REG_A0 + AN0] = State.regs[REG_D0 + DM1];
47 // 1111 0001 1101 AmDn; mov Am,Dn
48 8.0xf1+1101,2.AM1,2.DN0:D0a:::mov
54 State.regs[REG_D0 + DN0] = State.regs[REG_A0 + AM1];
58 // 1001 AnAn imm8....; mov imm8,An (imm8 is zero-extended)
59 // 1001 AmAn; mov Am,An (Am != An, save above when Am == An)
60 4.0x9,2.AM1,2.AN0:S0a:::mov
68 unsigned long immed = IMEM8_IMMED (cia, 1);
70 State.regs[REG_A0+AN0] = immed;
75 State.regs[REG_A0+AN0] = State.regs[REG_A0+AM1];
80 // 0011 11An; mov SP,An
81 4.0x3,11,2.AN0:S0b:::mov
87 State.regs[REG_A0 + AN0] = State.regs[REG_SP];
91 // 1111 0010 1111 Am00; mov Am,SP
92 8.0xf2+4.0xf,2.AM1,00:D0b:::mov
98 State.regs[REG_SP] = State.regs[REG_A0 + AM1];
102 // 1111 0010 1110 01Dn; mov PSW,Dn
103 8.0xf2+4.0xe,01,2.DN0:D0c:::mov
109 State.regs[REG_D0 + DN0] = PSW;
113 // 1111 0010 1111 Dm11; mov Dm,PSW
114 8.0xf2+4.0xf,2.DM1,11:D0d:::mov
120 PSW = State.regs[REG_D0 + DM1];
124 // 1111 0010 1110 00Dn; mov MDR,Dn
125 8.0xf2+4.0xe,00,2.DN0:D0e:::mov
131 State.regs[REG_D0 + DN0] = State.regs[REG_MDR];
135 // 1111 0010 1111 Dm10; mov Dm,MDR
136 8.0xf2+4.0xf,2.DM1,10:D0f:::mov
142 State.regs[REG_MDR] = State.regs[REG_D0 + DM1];
146 // 0111 DnAm; mov (Am),Dn
147 4.0x7,2.DN1,2.AM0:S0c:::mov
153 State.regs[REG_D0 + DN1] = load_word (State.regs[REG_A0 + AM0]);
157 // 1111 1000 0000 DnAm d8......; mov (d8,Am),Dn (d8 is sign-extended)
158 8.0xf8+4.0x0,2.DN1,2.AM0+8.D8:D1:::mov
164 State.regs[REG_D0 + DN1]
165 = load_word ((State.regs[REG_A0 + AM0] + EXTEND8 (D8)));
169 // 1111 1010 0000 DnAm d16.....; mov (d16,Am),Dn (d16 is sign-extended.)
170 8.0xfa+4.0x0,2.DN1,2.AM0+8.D16A+8.D16B:D2:::mov
176 State.regs[REG_D0 + DN1]
177 = load_word ((State.regs[REG_A0 + AM0] + EXTEND16 (FETCH16(D16A, D16B))));
181 // 1111 1100 0000 DnAm d32.....; mov (d32,Am),Dn
182 8.0xfc+4.0x0,2.DN1,2.AM0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::mov
188 State.regs[REG_D0 + DN1]
189 = load_word ((State.regs[REG_A0 + AM0]
190 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
194 // 0101 10Dn d8......; mov (d8,SP),Dn (d8 is zero-extended)
195 4.0x5,10,2.DN0+8.D8:S1:::mov
201 State.regs[REG_D0 + DN0] = load_word (State.regs[REG_SP] + D8);
205 // 1111 1010 1011 01Dn d16.....; mov (d16,SP),Dn (d16 is zero-extended.)
206 8.0xfa+4.0xb,01,2.DN0+8.IMM16A+8.IMM16B:D2a:::mov
212 State.regs[REG_D0 + DN0]
213 = load_word (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B));
217 // 1111 1010 1011 01Dn d32.....; mov (d32,SP),Dn
218 8.0xfc+4.0xb,01,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::mov
224 State.regs[REG_D0 + DN0]
225 = load_word (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
229 // 1111 0011 00Dn DiAm; mov (Di,Am),Dn
230 8.0xf3+00,2.DI,2.AM0,2.DN2:D0g:::mov
236 State.regs[REG_D0 + DN2]
237 = load_word ((State.regs[REG_A0 + AM0] + State.regs[REG_D0 + DI]));
241 // 0011 00Dn abs16...; mov (abs16),Dn (abs16 is zero-extended)
242 4.0x3,00,2.DN0+8.IMM16A+8.IMM16B:S2:::mov
248 State.regs[REG_D0 + DN0] = load_word (FETCH16(IMM16A, IMM16B));
251 // 1111 1100 1010 01Dn abs32...; mov (abs32),Dn
252 8.0xfc+4.0xa,01,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4b:::mov
258 State.regs[REG_D0 + DN0] = load_word (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
262 // 1111 0000 0000 AnAm; mov (Am),An
263 8.0xf0+4.0x0,2.AN1,2.AM0:D0h:::mov
269 State.regs[REG_A0 + AN1] = load_word (State.regs[REG_A0 + AM0]);
273 // 1111 1000 0010 AnAm d8......; mov (d8,Am),An (d8 is sign-extended)
274 8.0xf8+4.0x2,2.AN1,2.AM0+8.D8:D1a:::mov
280 State.regs[REG_A0 + AN1]
281 = load_word ((State.regs[REG_A0 + AM0] + EXTEND8 (D8)));
285 // 1111 1010 0010 AnAm d16.....; mov (d16,Am),An (d16 is sign-extended.)
286 8.0xfa+4.0x2,2.AN1,2.AM0+8.D16A+8.D16B:D2b:::mov
292 State.regs[REG_A0 + AN1]
293 = load_word ((State.regs[REG_A0 + AM0]
294 + EXTEND16 (FETCH16(D16A, D16B))));
298 // 1111 1100 0010 AnAm d32.....; mov (d32,Am),An
299 8.0xfc+4.0x2,2.AN1,2.AM0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4c:::mov
305 State.regs[REG_A0 + AN1]
306 = load_word ((State.regs[REG_A0 + AM0]
307 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
311 // 0101 11An d8......; mov (d8,SP),An (d8 is zero-extended)
312 4.0x5,11,2.AN0+8.D8:S1a:::mov
318 State.regs[REG_A0 + AN0]
319 = load_word (State.regs[REG_SP] + D8);
323 // 1111 1010 1011 00An d16.....; mov (d16,SP),An (d16 is zero-extended.)
324 8.0xfa+4.0xb,00,2.AN0+8.IMM16A+8.IMM16B:D2c:::mov
330 State.regs[REG_A0 + AN0]
331 = load_word (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B));
335 // 1111 1100 1011 00An d32.....; mov (d32,SP),An
336 8.0xfc+4.0xb,00,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4d:::mov
342 State.regs[REG_A0 + AN0]
343 = load_word (State.regs[REG_SP]
344 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
348 // 1111 0011 10An DiAm; mov (Di,Am),An
349 8.0xf3+10,2.AN2,2.DI,2.AM0:D0i:::mov
355 State.regs[REG_A0 + AN2]
356 = load_word ((State.regs[REG_A0 + AM0]
357 + State.regs[REG_D0 + DI]));
361 // 1111 1010 1010 00An abs16...; mov (abs16),An (abs16 is zero-extended)
362 8.0xfa+4.0xa,00,2.AN0+8.IMM16A+8.IMM16B:D2d:::mov
368 State.regs[REG_A0 + AN0] = load_word (FETCH16(IMM16A, IMM16B));
372 // 1111 1100 1010 00An abs32...; mov (abs32),An
373 8.0xfc+4.0xa,00,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4e:::mov
379 State.regs[REG_A0 + AN0]
380 = load_word (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
384 // 1111 1000 1111 00Am d8......; mov (d8,Am),SP (d8 is sign-extended)
385 8.0xf8+4.0xf,00,2.AM0+8.D8:D1b:::mov
392 = load_word ((State.regs[REG_A0 + AM0] + EXTEND8 (D8)));
396 // 0110 DmAn; mov Dm,(An)
397 4.0x6,2.DM1,2.AN0:S0d:::mov
403 store_word (State.regs[REG_A0 + AN0], State.regs[REG_D0 + DM1]);
407 // 1111 1000 0001 DmAn d8......; mov Dm,(d8,An) (d8 is sign-extended)
408 8.0xf8+4.0x1,2.DM1,2.AN0+8.D8:D1c:::mov
414 store_word ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)),
415 State.regs[REG_D0 + DM1]);
419 // 1111 1010 0001 DmAn d16.....; mov Dm,(d16,An) (d16 is sign-extended.)
420 8.0xfa+4.0x1,2.DM1,2.AN0+8.D16A+8.D16B:D2e:::mov
426 store_word ((State.regs[REG_A0 + AN0] + EXTEND16 (FETCH16(D16A, D16B))),
427 State.regs[REG_D0 + DM1]);
431 // 1111 1100 0001 DmAn d32.....; mov Dm,(d32,An)
432 8.0xfc+4.0x1,2.DM1,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4f:::mov
438 store_word ((State.regs[REG_A0 + AN0]
439 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)),
440 State.regs[REG_D0 + DM1]);
444 // 0100 Dm10 d8......; mov Dm,(d8,SP) (d8 is zero-extended)
445 4.0x4,2.DM1,10+8.D8:S1b:::mov
451 store_word (State.regs[REG_SP] + D8, State.regs[REG_D0 + DM1]);
455 // 1111 1010 1001 Dm01 d16.....; mov Dm,(d16,SP) (d16 is zero-extended.)
456 8.0xfa+4.0x9,2.DM1,01+8.IMM16A+8.IMM16B:D2f:::mov
462 store_word (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B),
463 State.regs[REG_D0 + DM1]);
467 // 1111 1100 1001 Dm01 d32.....; mov Dm,(d32,SP)
468 8.0xfc+4.0x9,2.DM1,01+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4g:::mov
474 store_word (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
475 State.regs[REG_D0 + DM1]);
479 // 1111 0011 01Dm DiAn; mov Dm,(Di,An)
480 8.0xf3+01,2.DM2,2.DI,2.AN0:D0j:::mov
486 store_word ((State.regs[REG_A0 + AN0] + State.regs[REG_D0 + DI]),
487 State.regs[REG_D0 + DM2]);
491 // 0000 Dm01 abs16..., mov Dm,(abs16) (abs16 is zero-extended).
492 4.0x0,2.DM1,01+8.IMM16A+8.IMM16B:S2a:::mov
498 store_word (FETCH16(IMM16A, IMM16B), State.regs[REG_D0 + DM1]);
502 // 1111 1100 1000 Dm01 abs32...; mov Dm,(abs32)
503 8.0xfc+4.0x8,2.DM1,01+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4h:::mov
509 store_word (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
510 State.regs[REG_D0 + DM1]);
514 // 1111 0000 0001 AmAn; mov Am,(An)
515 8.0xf0+4.0x1,2.AM1,2.AN0:D0k:::mov
521 store_word (State.regs[REG_A0 + AN0], State.regs[REG_A0 + AM1]);
525 // 1111 1000 0011 AmAn d8......; mov Am,(d8,An) (d8 is sign-extended)
526 8.0xf8+4.0x3,2.AM1,2.AN0+8.D8:D1d:::mov
532 store_word ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)),
533 State.regs[REG_A0 + AM1]);
537 // 1111 1010 0011 AmAn d16.....; mov Am,(d16,An) (d16 is sign-extended.)
538 8.0xfa+4.0x3,2.AM1,2.AN0+8.D16A+8.D16B:D2g:::mov
544 store_word ((State.regs[REG_A0 + AN0] + EXTEND16 (FETCH16(D16A, D16B))),
545 State.regs[REG_A0 + AM1]);
549 // 1111 1100 0011 AmAn d32.....; mov Am,(d32,An)
550 8.0xfc+4.0x3,2.AM1,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4i:::mov
556 store_word ((State.regs[REG_A0 + AN0]
557 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)),
558 State.regs[REG_A0 + AM1]);
562 // 0100 Am11 d8......; mov Am,(d8,SP) (d8 is zero-extended)
563 4.0x4,2.AM1,11+8.D8:S1c:::mov
569 store_word (State.regs[REG_SP] + (D8), State.regs[REG_A0 + (AM1)]);
573 // 1111 1010 1001 Am00 d16.....; mov Am,(d16,SP) (d16 is zero-extended.)
574 8.0xfa+4.0x9,2.AM1,00+8.IMM16A+8.IMM16B:D2h:::mov
580 store_word (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B),
581 State.regs[REG_A0 + AM1]);
585 // 1111 1100 1001 Am00 d32.....; mov Am,(d32,SP)
586 8.0xfc+4.0x9,2.AM1,00+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4j:::mov
592 store_word (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
593 State.regs[REG_A0 + AM1]);
597 // 1111 0011 11Am DiAn; mov Am,(Di,An)
598 8.0xf3+11,2.AM2,2.DI,2.AN0:D0l:::mov
604 store_word ((State.regs[REG_A0 + AN0] + State.regs[REG_D0 + DI]),
605 State.regs[REG_A0 + AM2]);
609 // 1111 1010 1000 Am00 abs16...; mov Am,(abs16) (abs16 is zero-extended)
610 8.0xfa+4.0x8,2.AM1,00+8.IMM16A+8.IMM16B:D2i:::mov
616 store_word (FETCH16(IMM16A, IMM16B),
617 State.regs[REG_A0 + AM1]);
621 // 1111 1100 1000 Am00 abs32...; mov Am,(abs32)
622 8.0xfc+4.0x8,2.AM1,00+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4k:::mov
628 store_word (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
629 State.regs[REG_A0 + AM1]);
633 // 1111 1000 1111 01An d8......; mov SP,(d8,An) (d8 is sign-extended)
634 8.0xf8+4.0xf,01,2.AN0+8.D8:D1e:::mov
640 store_word (State.regs[REG_A0 + AN0] + EXTEND8 (D8),
645 // 0010 11Dn imm16...; mov imm16,Dn (imm16 is sign-extended)
646 4.0x2,11,2.DN0+8.IMM16A+8.IMM16B:S2b:::mov
654 value = EXTEND16 (FETCH16(IMM16A, IMM16B));
655 State.regs[REG_D0 + DN0] = value;
659 // 1111 1100 1100 11Dn imm32...; mov imm32,Dn
660 8.0xfc+4.0xc,11,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4l:::mov
668 value = FETCH32(IMM32A, IMM32B, IMM32C, IMM32D);
669 State.regs[REG_D0 + DN0] = value;
673 // 0010 01An imm16...; mov imm16,An (imm16 is zero-extended)
674 4.0x2,01,2.AN0+8.IMM16A+8.IMM16B:S2c:::mov
682 value = FETCH16(IMM16A, IMM16B);
683 State.regs[REG_A0 + AN0] = value;
687 // 1111 1100 1101 11An imm32...; mov imm32,An
688 8.0xfc+4.0xd,11,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4m:::mov
694 State.regs[REG_A0 + AN0] = FETCH32(IMM32A, IMM32B, IMM32C, IMM32D);
698 // 1111 0000 0100 DnAm; movbu (Am),Dn
699 8.0xf0+4.0x4,2.DN1,2.AM0:D0:::movbu
705 State.regs[REG_D0 + DN1]
706 = load_byte (State.regs[REG_A0 + AM0]);
710 // 1111 1000 0100 DnAm d8......; movbu (d8,Am),Dn (d8 is sign-extended)
711 8.0xf8+4.0x4,2.DN1,2.AM0+8.D8:D1f:::movbu
717 State.regs[REG_D0 + DN1]
718 = load_byte ((State.regs[REG_A0 + AM0] + EXTEND8 (D8)));
722 // 1111 1010 0100 DnAm d16.....; movbu (d16,Am),Dn (d16 is sign-extended.)
723 8.0xfa+4.0x4,2.DN1,2.AM0+8.D16A+8.D16B:D2:::movbu
729 State.regs[REG_D0 + DN1]
730 = load_byte ((State.regs[REG_A0 + AM0]
731 + EXTEND16 (FETCH16(D16A, D16B))));
735 // 1111 1100 0100 DnAm d32.....; movbu (d32,Am),Dn
736 8.0xfc+4.0x4,2.DN1,2.AM0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::movbu
742 State.regs[REG_D0 + DN1]
743 = load_byte ((State.regs[REG_A0 + AM0]
744 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
748 // 1111 1000 1011 10Dn d8......; movbu (d8,SP),Dn (d8 is zero-extended)
749 8.0xf8+4.0xb,10,2.DN0+8.D8:D1a:::movbu
755 State.regs[REG_D0 + DN0]
756 = load_byte ((State.regs[REG_SP] + (D8)));
760 // 1111 1010 1011 10Dn d16.....; movbu (d16,SP),Dn (d16 is zero-extended.)
761 8.0xfa+4.0xb,10,2.DN0+8.IMM16A+8.IMM16B:D2a:::movbu
767 State.regs[REG_D0 + DN0]
768 = load_byte ((State.regs[REG_SP]
769 + FETCH16(IMM16A, IMM16B)));
773 // 1111 1100 1011 10Dn d32.....; movbu (d32,SP),Dn
774 8.0xfc+4.0xb,10,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::movbu
780 State.regs[REG_D0 + DN0]
781 = load_byte (State.regs[REG_SP]
782 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
786 // 1111 0100 00Dn DiAm; movbu (Di,Am),Dn
787 8.0xf4+00,2.DN2,2.DI,2.AM0:D0a:::movbu
793 State.regs[REG_D0 + DN2]
794 = load_byte ((State.regs[REG_A0 + AM0]
795 + State.regs[REG_D0 + DI]));
799 // 0011 01Dn abs16...; movbu (abs16),Dn (abs16 is zero-extended)
800 4.0x3,01,2.DN0+8.IMM16A+8.IMM16B:S2:::movbu
806 State.regs[REG_D0 + DN0] = load_byte (FETCH16(IMM16A, IMM16B));
810 // 1111 1100 1010 10Dn abs32...; movbu (abs32),Dn
811 8.0xfc+4.0xa,10,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4b:::movbu
817 State.regs[REG_D0 + DN0]
818 = load_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
822 // 1111 0000 0101 DmAn; movbu Dm,(An)
823 8.0xf0+4.0x5,2.DM1,2.AN0:D0b:::movbu
829 store_byte (State.regs[REG_A0 + AN0], State.regs[REG_D0 + DM1]);
833 // 1111 1000 0101 DmAn d8......; movbu Dm,(d8,An) (d8 is sign-extended)
834 8.0xf8+4.0x5,2.DM1,2.AN0+8.D8:D1b:::movbu
840 store_byte ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)),
841 State.regs[REG_D0 + DM1]);
845 // 1111 1010 0101 DmAn d16.....; movbu Dm,(d16,An) (d16 is sign-extended.)
846 8.0xfa+4.0x5,2.DM1,2.AN0+8.D16A+8.D16B:D2b:::movbu
852 store_byte ((State.regs[REG_A0 + AN0] + EXTEND16 (FETCH16(D16A, D16B))),
853 State.regs[REG_D0 + DM1]);
857 // 1111 1100 0101 DmAn d32.....; movbu Dm,(d32,An)
858 8.0xfc+4.0x5,2.DM1,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4c:::movbu
864 store_byte ((State.regs[REG_A0 + AN0]
865 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)),
866 State.regs[REG_D0 + DM1]);
870 // 1111 1000 1001 Dm10 d8......; movbu Dm,(d8,SP) (d8 is zero-extended)
871 8.0xf8+4.0x9,2.DM1,10+8.D8:D1c:::movbu
877 store_byte (State.regs[REG_SP] + (D8), State.regs[REG_D0 + DM1]);
881 // 1111 1010 1001 Dm10 d16.....; movbu Dm,(d16,SP) (d16 is zero-extended.)
882 8.0xfa+4.0x9,2.DM1,10+8.IMM16A+8.IMM16B:D2c:::movbu
888 store_byte (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B),
889 State.regs[REG_D0 + DM1]);
893 // 1111 1100 1001 Dm10 d32.....; movbu Dm,(d32,SP)
894 8.0xfc+4.0x9,2.DM1,10+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4d:::movbu
900 store_byte (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
901 State.regs[REG_D0 + DM1]);
905 // 1111 0100 01Dm DiAn; movbu Dm,(Di,An)
906 8.0xf4+01,2.DM2,2.DI,2.AN0:D0c:::movbu
912 store_byte ((State.regs[REG_A0 + AN0] + State.regs[REG_D0 + DI]),
913 State.regs[REG_D0 + DM2]);
917 // 0000 Dm10 abs16...; movbu Dm,(abs16) (abs16 is zero-extended)
918 4.0x0,2.DM1,10+8.IMM16A+8.IMM16B:S2a:::movbu
924 store_byte (FETCH16(IMM16A, IMM16B),
925 State.regs[REG_D0 + DM1]);
929 // 1111 1100 1000 Dm10 abs32...; movbu Dm,(abs32)
930 8.0xfc+4.0x8,2.DM1,10+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4e:::movbu
936 store_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
937 State.regs[REG_D0 + DM1]);
941 // 1111 0000 0110 DnAm; movhu (Am),Dn
942 8.0xf0+4.0x6,2.DN1,2.AM0:D0:::movhu
948 State.regs[REG_D0 + DN1]
949 = load_half (State.regs[REG_A0 + AM0]);
953 // 1111 1000 0110 DnAm d8......; movhu (d8,Am),Dn (d8 is sign-extended)
954 8.0xf8+4.0x6,2.DN1,2.AM0+8.D8:D1d:::movhu
960 State.regs[REG_D0 + DN1]
961 = load_half ((State.regs[REG_A0 + AM0] + EXTEND8 (D8)));
965 // 1111 1010 0110 DnAm d16.....; movhu (d16,Am),Dn (d16 is sign-extended.)
966 8.0xfa+4.0x6,2.DN1,2.AM0+8.D16A+8.D16B:D2:::movhu
972 State.regs[REG_D0 + DN1]
973 = load_half ((State.regs[REG_A0 + AM0]
974 + EXTEND16 (FETCH16(D16A, D16B))));
978 // 1111 1100 0110 DnAm d32.....; movhu (d32,Am),Dn
979 8.0xfc+4.0x6,2.DN1,2.AM0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::movhu
985 State.regs[REG_D0 + DN1]
986 = load_half ((State.regs[REG_A0 + AM0]
987 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
991 // 1111 1000 1011 11Dn d8.....; movhu (d8,SP),Dn (d8 is zero-extended)
992 8.0xf8+4.0xb,11,2.DN0+8.D8:D1a:::movhu
998 State.regs[REG_D0 + DN0]
999 = load_half ((State.regs[REG_SP] + (D8)));
1003 // 1111 1010 1011 11Dn d16.....; movhu (d16,SP),Dn (d16 is zero-extended.)
1004 8.0xfa+4.0xb,11,2.DN0+8.IMM16A+8.IMM16B:D2a:::movhu
1010 State.regs[REG_D0 + DN0]
1011 = load_half ((State.regs[REG_SP] + FETCH16(IMM16A, IMM16B)));
1015 // 1111 1100 1011 11Dn d32.....; movhu (d32,SP),Dn
1016 8.0xfc+4.0xb,11,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::movhu
1022 State.regs[REG_D0 + DN0]
1023 = load_half (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
1027 // 1111 0100 10Dn DiAm; movhu (Di,Am),Dn
1028 8.0xf4+10,2.DN2,2.DI,2.AM0:D0a:::movhu
1034 State.regs[REG_D0 + DN2]
1035 = load_half ((State.regs[REG_A0 + AM0] + State.regs[REG_D0 + DI]));
1039 // 0011 10Dn abs16...; movhu (abs16),Dn (abs16 is zero-extended)
1040 4.0x3,10,2.DN0+8.IMM16A+8.IMM16B:S2:::movhu
1046 State.regs[REG_D0 + DN0] = load_half (FETCH16(IMM16A, IMM16B));
1050 // 1111 1100 1010 11Dn abs32...; movhu (abs32),Dn
1051 8.0xfc+4.0xa,11,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4b:::movhu
1057 State.regs[REG_D0 + DN0]
1058 = load_half (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
1062 // 1111 0000 0111 DmAn; movhu Dm,(An)
1063 8.0xf0+4.0x7,2.DM1,2.AN0:D0b:::movhu
1069 store_half (State.regs[REG_A0 + AN0],
1070 State.regs[REG_D0 + DM1]);
1074 // 1111 1000 0111 DmAn d8......; movhu Dm,(d8,An) (d8 is sign-extended)
1075 8.0xf8+4.0x7,2.DM1,2.AN0+8.D8:D1b:::movhu
1081 store_half ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)),
1082 State.regs[REG_D0 + DM1]);
1086 // 1111 1010 0111 DnAm d16.....; movhu Dm,(d16,An) (d16 is sign-extended.)
1087 8.0xfa+4.0x7,2.DM1,2.AN0+8.D16A+8.D16B:D2b:::movhu
1093 store_half ((State.regs[REG_A0 + AN0] + EXTEND16 (FETCH16(D16A, D16B))),
1094 State.regs[REG_D0 + DM1]);
1098 // 1111 1100 0111 DmAn d32.....; movhu Dm,(d32,An)
1099 8.0xfc+4.0x7,2.DM1,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4c:::movhu
1105 store_half ((State.regs[REG_A0 + AN0]
1106 + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)),
1107 State.regs[REG_D0 + DM1]);
1111 // 1111 1000 1001 Dm11 d8....; movhu Dm,(d8,SP) (d8 is zero-extended)
1112 8.0xf8+4.0x9,2.DM1,11+8.D8:D1c:::movhu
1118 store_half (State.regs[REG_SP] + (D8),
1119 State.regs[REG_D0 + DM1]);
1123 // 1111 1010 1001 Dm11 d16.....; movhu Dm,(d16,SP) (d16 is zero-extended.)
1124 8.0xfa+4.0x9,2.DM1,11+8.IMM16A+8.IMM16B:D2c:::movhu
1130 store_half (State.regs[REG_SP] + FETCH16(IMM16A, IMM16B),
1131 State.regs[REG_D0 + DM1]);
1135 // 1111 1100 1001 Dm11 d32.....; movhu Dm,(d32,SP)
1136 8.0xfc+4.0x9,2.DM1,11+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4d:::movhu
1142 store_half (State.regs[REG_SP] + FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
1143 State.regs[REG_D0 + DM1]);
1147 // 1111 0100 11Dm DiAn; movhu Dm,(Di,An)
1148 8.0xf4+11,2.DM2,2.DI,2.AN0:D0c:::movhu
1154 store_half ((State.regs[REG_A0 + AN0] + State.regs[REG_D0 + DI]),
1155 State.regs[REG_D0 + DM2]);
1159 // 0000 Dm11 abs16...; movhu Dm,(abs16) (abs16 is zero-extended)
1160 4.0x0,2.DM1,11+8.IMM16A+8.IMM16B:S2a:::movhu
1166 store_half (FETCH16(IMM16A, IMM16B), State.regs[REG_D0 + DM1]);
1170 // 1111 1100 1000 Dm11 abs32...; movhu Dm,(abs32)
1171 8.0xfc+4.0x8,2.DM1,11+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4e:::movhu
1177 store_half (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
1178 State.regs[REG_D0 + DM1]);
1182 // 1111 0010 1101 00Dn; ext Dn
1183 8.0xf2+4.0xd,00,2.DN0:D0:::ext
1189 if (State.regs[REG_D0 + DN0] & 0x80000000)
1190 State.regs[REG_MDR] = -1;
1192 State.regs[REG_MDR] = 0;
1196 // 0001 00Dn; extb Dn
1197 4.0x1,00,2.DN0:S0:::extb
1203 State.regs[REG_D0 + DN0] = EXTEND8 (State.regs[REG_D0 + DN0]);
1207 // 0001 01Dn; extbu Dn
1208 4.0x1,01,2.DN0:S0:::extbu
1214 State.regs[REG_D0 + DN0] &= 0xff;
1218 // 0001 10Dn; exth Dn
1219 4.0x1,10,2.DN0:S0:::exth
1225 State.regs[REG_D0 + DN0] = EXTEND16 (State.regs[REG_D0 + DN0]);
1229 // 0001 11Dn; exthu Dn
1230 4.0x1,11,2.DN0:S0:::exthu
1236 State.regs[REG_D0 + DN0] &= 0xffff;
1240 // 1100 1110 regs....; movm (SP),regs
1241 8.0xce+8.REGS:S1:::movm
1246 unsigned long sp = State.regs[REG_SP];
1255 State.regs[REG_LAR] = load_word (sp);
1257 State.regs[REG_LIR] = load_word (sp);
1259 State.regs[REG_MDR] = load_word (sp);
1261 State.regs[REG_A0 + 1] = load_word (sp);
1263 State.regs[REG_A0] = load_word (sp);
1265 State.regs[REG_D0 + 1] = load_word (sp);
1267 State.regs[REG_D0] = load_word (sp);
1273 State.regs[REG_A0 + 3] = load_word (sp);
1279 State.regs[REG_A0 + 2] = load_word (sp);
1285 State.regs[REG_D0 + 3] = load_word (sp);
1291 State.regs[REG_D0 + 2] = load_word (sp);
1295 /* And make sure to update the stack pointer. */
1296 State.regs[REG_SP] = sp;
1300 // 1100 1111 regs....; movm regs,(SP)
1301 8.0xcf+8.REGS:S1a:::movm
1306 unsigned long sp = State.regs[REG_SP];
1315 store_word (sp, State.regs[REG_D0 + 2]);
1321 store_word (sp, State.regs[REG_D0 + 3]);
1327 store_word (sp, State.regs[REG_A0 + 2]);
1333 store_word (sp, State.regs[REG_A0 + 3]);
1339 store_word (sp, State.regs[REG_D0]);
1341 store_word (sp, State.regs[REG_D0 + 1]);
1343 store_word (sp, State.regs[REG_A0]);
1345 store_word (sp, State.regs[REG_A0 + 1]);
1347 store_word (sp, State.regs[REG_MDR]);
1349 store_word (sp, State.regs[REG_LIR]);
1351 store_word (sp, State.regs[REG_LAR]);
1355 /* And make sure to update the stack pointer. */
1356 State.regs[REG_SP] = sp;
1360 // 0000 Dn00; clr Dn
1361 4.0x0,2.DN1,00:S0:::clr
1367 State.regs[REG_D0 + DN1] = 0;
1370 PSW &= ~(PSW_V | PSW_C | PSW_N);
1374 // 1110 DmDn; add Dm,Dn
1375 4.0xe,2.DM1,2.DN0:S0:::add
1381 genericAdd(State.regs[REG_D0 + DM1], REG_D0 + DN0);
1384 // 1111 0001 0110 DmAn; add Dm,An
1385 8.0xf1+4.0x6,2.DM1,2.AN0:D0:::add
1391 unsigned long reg1, reg2, value;
1394 genericAdd(State.regs[REG_D0 + DM1], REG_A0 + AN0);
1398 // 1111 0001 0101 AmDn; add Am,Dn
1399 8.0xf1+4.0x5,2.AM1,2.DN0:D0a:::add
1405 genericAdd(State.regs[REG_A0 + AM1], REG_D0 + DN0);
1409 // 1111 0001 0111 AmAn; add Am,An
1410 8.0xf1+4.0x7,2.AM1,2.AN0:D0b:::add
1416 genericAdd(State.regs[REG_A0 + AM1], REG_A0 + AN0);
1420 // 0010 10Dn imm8....; add imm8,Dn (imm8 is sign-extended)
1421 4.0x2,10,2.DN0+8.IMM8:S1:::add
1427 genericAdd(EXTEND8(IMM8), REG_D0 + DN0);
1431 // 1111 1010 1100 00Dn imm16...; add imm16,Dn
1432 8.0xfa+4.0xc,00,2.DN0+8.IMM16A+8.IMM16B:D2:::add
1438 genericAdd(EXTEND16(FETCH16(IMM16A, IMM16B)), REG_D0 + DN0);
1442 // 1111 1100 1100 00Dn imm32...; add imm32,Dn
1443 8.0xfc+4.0xc,00,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::add
1449 genericAdd(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_D0 + DN0);
1453 // 0010 00An imm8....; add imm8,An (imm8 is sign-extended)
1454 4.0x2,00,2.AN0+8.IMM8:S1a:::add
1460 genericAdd(EXTEND8(IMM8), REG_A0 + AN0);
1464 // 1111 1010 1101 00An imm16...; add imm16,An (imm16 is sign-extended.)
1465 8.0xfa+4.0xd,00,2.AN0+8.IMM16A+8.IMM16B:D2a:::add
1471 genericAdd(EXTEND16(FETCH16(IMM16A, IMM16B)), REG_A0 + AN0);
1475 // 1111 1100 1101 00An imm32...; add imm32,An
1476 8.0xfc+4.0xd,00,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::add
1482 genericAdd(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_A0 + AN0);
1486 // 1111 1000 1111 1110 imm8....; add imm8,SP (imm8 is sign-extended.)
1487 8.0xf8+8.0xfe+8.IMM8:D1:::add
1494 // Note: no PSW changes.
1496 imm = EXTEND8 (IMM8);
1497 State.regs[REG_SP] += imm;
1501 // 1111 1010 1111 1110 imm16...; add imm16,SP (imm16 is sign-extended.)
1502 8.0xfa+8.0xfe+8.IMM16A+8.IMM16B:D2b:::add
1509 // Note: no PSW changes.
1511 imm = EXTEND16 (FETCH16(IMM16A, IMM16B));
1512 State.regs[REG_SP] += imm;
1516 // 1111 1100 1111 1110 imm32...; add imm32,SP
1517 8.0xfc+8.0xfe+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4b:::add
1524 // Note: no PSW changes.
1526 imm = FETCH32(IMM32A, IMM32B, IMM32C, IMM32D);
1527 State.regs[REG_SP] += imm;
1531 // 1111 0001 0100 DmDn; addc Dm,Dn
1532 8.0xf1+4.0x4,2.DM1,2.DN0:D0:::addc
1538 unsigned long reg1, reg2, sum;
1541 reg1 = State.regs[REG_D0 + DM1];
1542 reg2 = State.regs[REG_D0 + DN0];
1543 sum = reg1 + reg2 + ((PSW & PSW_C) != 0);
1544 State.regs[REG_D0 + DN0] = sum;
1547 n = (sum & 0x80000000);
1548 c = (sum < reg1) || (sum < reg2);
1549 v = ((reg2 & 0x80000000) == (reg1 & 0x80000000)
1550 && (reg2 & 0x80000000) != (sum & 0x80000000));
1552 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1553 PSW |= ((z ? PSW_Z : 0) | ( n ? PSW_N : 0)
1554 | (c ? PSW_C : 0) | (v ? PSW_V : 0));
1558 // 1111 0001 0000 DmDn; sub Dm,Dn
1559 8.0xf1+4.0x0,2.DM1,2.DN0:D0:::sub
1565 genericSub(State.regs[REG_D0 + DM1], REG_D0 + DN0);
1568 // 1111 0001 0010 DmAn; sub DmAn
1569 8.0xf1+4.0x2,2.DM1,2.AN0:D0a:::sub
1575 genericSub(State.regs[REG_D0 + DM1], REG_A0 + AN0);
1579 // 1111 0001 0001 AmDn; sub AmDn
1580 8.0xf1+4.0x1,2.AM1,2.DN0:D0b:::sub
1586 genericSub(State.regs[REG_A0 + AM1], REG_D0 + DN0);
1590 // 1111 0001 0011 AmAn; sub Am,An
1591 8.0xf1+4.0x3,2.AM1,2.AN0:D0c:::sub
1597 genericSub(State.regs[REG_A0 + AM1], REG_A0 + AN0);
1601 // 1111 1100 1100 01Dn imm32...; sub imm32,Dn
1602 8.0xfc+4.0xc,01,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::sub
1608 genericSub(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_D0 + DN0);
1612 // 1111 1100 1101 01An imm32...; sub imm32,An
1613 8.0xfc+4.0xd,01,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::sub
1619 genericSub(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_A0 + AN0);
1623 // 1111 0001 1000 DmDn; subc Dm,Dn
1624 8.0xf1+4.0x8,2.DM1,2.DN0:D0:::subc
1630 unsigned long reg1, reg2, difference;
1633 reg1 = State.regs[REG_D0 + DM1];
1634 reg2 = State.regs[REG_D0 + DN0];
1635 difference = reg2 - reg1 - ((PSW & PSW_C) != 0);
1636 State.regs[REG_D0 + DN0] = difference;
1638 z = (difference == 0);
1639 n = (difference & 0x80000000);
1641 v = ((reg2 & 0x80000000) != (reg1 & 0x80000000)
1642 && (reg2 & 0x80000000) != (difference & 0x80000000));
1644 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1645 PSW |= ((z ? PSW_Z : 0) | ( n ? PSW_N : 0)
1646 | (c ? PSW_C : 0) | (v ? PSW_V : 0));
1650 // 1111 0010 0100 DmDn; mul Dm,Dn
1651 8.0xf2+4.0x4,2.DM1,2.DN0:D0:::mul
1656 unsigned long long temp;
1660 temp = ((signed64)(signed32)State.regs[REG_D0 + DN0]
1661 * (signed64)(signed32)State.regs[REG_D0 + DM1]);
1662 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
1663 State.regs[REG_MDR] = (temp & 0xffffffff00000000LL) >> 32;;
1664 z = (State.regs[REG_D0 + DN0] == 0);
1665 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1666 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1667 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1671 // 1111 0010 0101 DmDn; mulu Dm,Dn
1672 8.0xf2+4.0x5,2.DM1,2.DN0:D0:::mulu
1677 unsigned long long temp;
1681 temp = ((unsigned64)State.regs[REG_D0 + DN0]
1682 * (unsigned64)State.regs[REG_D0 + DM1]);
1683 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
1684 State.regs[REG_MDR] = (temp & 0xffffffff00000000LL) >> 32;
1685 z = (State.regs[REG_D0 + DN0] == 0);
1686 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1687 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1688 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1692 // 1111 0010 0110 DmDn; div Dm,Dn
1693 8.0xf2+4.0x6,2.DM1,2.DN0:D0:::div
1702 temp = State.regs[REG_MDR];
1704 temp |= State.regs[REG_D0 + DN0];
1705 State.regs[REG_MDR] = temp % (long)State.regs[REG_D0 + DM1];
1706 temp /= (long)State.regs[REG_D0 + DM1];
1707 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
1708 z = (State.regs[REG_D0 + DN0] == 0);
1709 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1710 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1711 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1715 // 1111 0010 0111 DmDn; divu Dm,Dn
1716 8.0xf2+4.0x7,2.DM1,2.DN0:D0:::divu
1721 unsigned long long temp;
1725 temp = State.regs[REG_MDR];
1727 temp |= State.regs[REG_D0 + DN0];
1728 State.regs[REG_MDR] = temp % State.regs[REG_D0 + DM1];
1729 temp /= State.regs[REG_D0 + DM1];
1730 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
1731 z = (State.regs[REG_D0 + DN0] == 0);
1732 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1733 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1734 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1738 // 0100 Dn00; inc Dn
1739 4.0x4,2.DN1,00:S0:::inc
1748 genericAdd(imm, REG_D0 + DN1);
1753 4.0x4,2.AN1,01:S0a:::inc
1759 State.regs[REG_A0 + AN1] += 1;
1763 // 0101 00An; inc4 An
1764 4.0x5,00,2.AN0:S0:::inc4
1770 State.regs[REG_A0 + AN0] += 4;
1774 // 1010 DnDn imm8....; cmp imm8,Dn (imm8 is sign-extended.)
1775 // 1010 DmDn; cmp Dm,Dn (Dm != Dn, see above when Dm == Dn)
1776 4.0xa,2.DM1,2.DN0:S0:::cmp
1783 signed32 immed = EXTEND8 (IMEM8_IMMED (cia, 1));
1786 genericCmp(immed, State.regs[REG_D0 + DN0]);
1791 genericCmp(State.regs[REG_D0 + DM1], State.regs[REG_D0 + DN0]);
1796 // 1111 0001 1010 DmAn; cmp Dm,An
1797 8.0xf1+4.0xa,2.DM1,2.AN0:D0:::cmp
1803 genericCmp(State.regs[REG_D0 + DM1], State.regs[REG_A0 + AN0]);
1807 // 1111 0001 1001 AmDn; cmp Am,Dn
1808 8.0xf1+4.0x9,2.AM1,2.DN0:D0a:::cmp
1814 genericCmp(State.regs[REG_A0 + AM1], State.regs[REG_D0 + DN0]);
1818 // 1011 AnAn imm8....; cmp imm8,An (imm8 is zero-extended.)
1819 // 1011 AmAn; cmp Am,An (Dm != Dn, see above when Dm == Dn)
1820 4.0xb,2.AM1,2.AN0:S0a:::cmp
1828 genericCmp(EXTEND8 (IMEM8_IMMED (cia, 1)),
1829 State.regs[REG_A0 + AN0]);
1835 genericCmp(State.regs[REG_A0 + AM1], State.regs[REG_A0 + AN0]);
1840 // 1111 1010 1100 10Dn imm16...; cmp imm16,Dn (imm16 is sign-extended.)
1841 8.0xfa+4.0xc,10,2.DN0+8.IMM16A+8.IMM16B:D2:::cmp
1847 genericCmp(EXTEND16(FETCH16(IMM16A, IMM16B)),
1848 State.regs[REG_D0 + DN0]);
1852 // 1111 1100 1100 10Dn imm32...; cmp imm32,Dn
1853 8.0xfc+4.0xc,10,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::cmp
1859 genericCmp(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
1860 State.regs[REG_D0 + DN0]);
1864 // 1111 1010 1101 10An imm16...; cmp imm16,An (imm16 is zero-extended.)
1865 8.0xfa+4.0xd,10,2.AN0+8.IMM16A+8.IMM16B:D2a:::cmp
1871 genericCmp(FETCH16(IMM16A, IMM16B),
1872 State.regs[REG_A0 + AN0]);
1876 // 1111 1100 1101 10An imm32...; cmp imm32,An
1877 8.0xfc+4.0xd,10,2.AN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4a:::cmp
1883 genericCmp(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
1884 State.regs[REG_A0 + AN0]);
1888 // 1111 0010 0000 DmDn; and Dm,Dn
1889 8.0xf2+4.0x0,2.DM1,2.DN0:D0:::and
1897 State.regs[REG_D0 + DN0] &= State.regs[REG_D0 + DM1];
1898 z = (State.regs[REG_D0 + DN0] == 0);
1899 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1900 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1901 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1905 // 1111 1000 1110 00Dn imm8....; and imm8,Dn (imm8 is zero-extended.)
1906 8.0xf8+4.0xe,00,2.DN0+8.IMM8:D1:::and
1914 State.regs[REG_D0 + DN0] &= IMM8;
1915 z = (State.regs[REG_D0 + DN0] == 0);
1916 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1917 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1918 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1922 // 1111 1010 1110 00Dn imm16...; and imm16,Dn (imm16 is zero-extended.)
1923 8.0xfa+4.0xe,00,2.DN0+8.IMM16A+8.IMM16B:D2:::and
1931 State.regs[REG_D0 + DN0] &= FETCH16(IMM16A, IMM16B);
1932 z = (State.regs[REG_D0 + DN0] == 0);
1933 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1934 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1935 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1939 // 1111 1100 1110 00Dn imm32...; and imm32,Dn
1940 8.0xfc+4.0xe,00,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::and
1948 State.regs[REG_D0 + DN0]
1949 &= FETCH32(IMM32A, IMM32B, IMM32C, IMM32D);
1950 z = (State.regs[REG_D0 + DN0] == 0);
1951 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
1952 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
1953 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
1957 // 1111 1010 1111 1100 imm16...; and imm16,PSW (imm16 is zero-extended.)
1958 8.0xfa+8.0xfc+8.IMM16A+8.IMM16B:D2a:::and
1964 PSW &= FETCH16(IMM16A, IMM16B);
1969 // 1111 0010 0001 DmDn; or DmDn
1970 8.0xf2+4.0x1,2.DM1,2.DN0:D0:::or
1976 genericOr(State.regs[REG_D0 + DM1], REG_D0 + DN0);
1980 // 1111 1000 1110 01Dn imm8....; or imm8,Dn (imm8 is zero-extended.)n
1981 8.0xf8+4.0xe,01,2.DN0+8.IMM8:D1:::or
1987 genericOr(IMM8, REG_D0 + DN0);
1991 // 1111 1010 1110 01Dn imm16...; or imm16,DN (imm16 is zero-extended.)
1992 8.0xfa+4.0xe,01,2.DN0+8.IMM16A+8.IMM16B:D2:::or
1998 genericOr(FETCH16(IMM16A, IMM16B), REG_D0 + DN0);
2002 // 1111 1100 1110 01Dn imm32...; or imm32,Dn
2003 8.0xfc+4.0xe,01,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::or
2009 genericOr(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_D0 + DN0);
2013 // 1111 1010 1111 1101 imm16...; or imm16,PSW (imm16 is zero-extended.)
2014 8.0xfa+8.0xfd+8.IMM16A+8.IMM16B:D2a:::or
2020 PSW |= FETCH16(IMM16A, IMM16B);
2024 // 1111 0010 0010 DmDn; xor Dm,Dn
2025 8.0xf2+4.0x2,2.DM1,2.DN0:D0:::xor
2031 genericXor(State.regs[REG_D0 + DM1], REG_D0 + DN0);
2035 // 1111 1010 1110 10Dn imm16...; xor imm16,Dn (imm16 is zero-extended.)
2036 8.0xfa+4.0xe,10,2.DN0+8.IMM16A+8.IMM16B:D2:::xor
2042 genericXor(FETCH16(IMM16A, IMM16B), REG_D0 + DN0);
2046 // 1111 1100 1110 10Dn imm32...; xor imm32,Dn
2047 8.0xfc+4.0xe,10,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::xor
2053 genericXor(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), REG_D0 + DN0);
2057 // 1111 0010 0011 00Dn; not Dn
2058 8.0xf2+4.0x3,00,2.DN0:D0:::not
2066 State.regs[REG_D0 + DN0] = ~State.regs[REG_D0 + DN0];
2067 z = (State.regs[REG_D0 + DN0] == 0);
2068 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2069 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2070 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
2074 // 1111 1000 1110 11Dn imm8....; btst imm8,Dn (imm8 is zero-extended.)
2075 8.0xf8+4.0xe,11,2.DN0+8.IMM8:D1:::btst
2081 genericBtst(IMM8, State.regs[REG_D0 + DN0]);
2085 // 1111 1010 1110 11Dn imm16.....; btst imm16,Dn (imm16 is zero-extended.)
2086 8.0xfa+4.0xe,11,2.DN0+8.IMM16A+8.IMM16B:D2:::btst
2092 genericBtst(FETCH16(IMM16A, IMM16B), State.regs[REG_D0 + DN0]);
2096 // 1111 1100 1110 11Dn imm32...; btst imm32,Dn
2097 8.0xfc+4.0xe,11,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::btst
2103 genericBtst(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D),
2104 State.regs[REG_D0 + DN0]);
2108 // 1111 1110 0000 0010 abs32... imm8....; btst imm8,(abs32) (imm8 is zero-extended., processing unit: byte)
2109 8.0xfe+8.0x02+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D+8.IMM8:D5:::btst
2116 load_byte(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
2120 // 1111 1010 1111 10An d8...... imm8....;
2121 // btst imm8,(d8,An) (d8 is sign-extended,imm8 is zero-extended., processing unit: byte)
2122 8.0xfa+4.0xf,10,2.AN0+8.D8+8.IMM8:D2a:::btst
2129 load_byte(State.regs[REG_A0 + AN0] + EXTEND8(D8)));
2133 // 1111 0000 1000 DmAn; bset Dm,(An) (Processing unit byte)
2134 8.0xf0+4.8,2.DM1,2.AN0:D0:::bset
2143 temp = load_byte (State.regs[REG_A0 + AN0]);
2144 z = (temp & State.regs[REG_D0 + DM1]) == 0;
2145 temp |= State.regs[REG_D0 + DM1];
2146 store_byte (State.regs[REG_A0 + AN0], temp);
2147 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2148 PSW |= (z ? PSW_Z : 0);
2152 // 1111 1110 0000 0000 abs32... imm8....;
2153 // bset imm8,(abs32) (imm8 is zero-extended., processing unit: byte)
2154 8.0xfe+8.0x00+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D+8.IMM8:D5:::bset
2163 temp = load_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
2164 z = (temp & IMM8) == 0;
2166 store_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), temp);
2167 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2168 PSW |= (z ? PSW_Z : 0);
2172 // 1111 1010 1111 00AnAn d8...... imm8....;
2173 // bset imm8,(d8,An) (d8 is sign-extended, imm8 is zero-extended., processing unit: byte)
2174 8.0xfa+4.0xf,00,2.AN0+8.D8+8.IMM8:D2:::bset
2183 temp = load_byte ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)));
2184 z = (temp & (IMM8)) == 0;
2186 store_byte ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)), temp);
2187 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2188 PSW |= (z ? PSW_Z : 0);
2192 // 1111 0000 1001 DmAn; bclr Dm,(An) (Processing unit byte)
2193 8.0xf0+4.0x9,2.DM1,2.AN0:D0:::bclr
2202 temp = load_byte (State.regs[REG_A0 + AN0]);
2203 z = (temp & State.regs[REG_D0 + DM1]) == 0;
2204 temp = temp & ~State.regs[REG_D0 + DM1];
2205 store_byte (State.regs[REG_A0 + AN0], temp);
2206 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2207 PSW |= (z ? PSW_Z : 0);
2211 // 1111 1110 0000 0001 abs32... imm8....;
2212 // bclr imm8,(abs32) (imm8 is zero-extended., processing unit: byte)
2213 8.0xfe+8.0x01+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D+8.IMM8:D5:::bclr
2222 temp = load_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D));
2223 z = (temp & IMM8) == 0;
2224 temp = temp & ~(IMM8);
2225 store_byte (FETCH32(IMM32A, IMM32B, IMM32C, IMM32D), temp);
2226 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2227 PSW |= (z ? PSW_Z : 0);
2231 // 1111 1010 1111 01An d8...... imm8....;
2232 // bclr imm8,(d8,An) (d8 is sign-extended, imm8 is zero-extended., processing unit: byte)
2233 8.0xfa+4.0xf,01,2.AN0+8.D8+8.IMM8:D2:::bclr
2242 temp = load_byte ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)));
2243 z = (temp & (IMM8)) == 0;
2244 temp = temp & ~(IMM8);
2245 store_byte ((State.regs[REG_A0 + AN0] + EXTEND8 (D8)), temp);
2246 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2247 PSW |= (z ? PSW_Z : 0);
2251 // 1111 0010 1011 DmDn; asr Dm,Dn
2252 8.0xf2+4.0xb,2.DM1,2.DN0:D0:::asr
2261 temp = State.regs[REG_D0 + DN0];
2263 temp >>= State.regs[REG_D0 + DM1];
2264 State.regs[REG_D0 + DN0] = temp;
2265 z = (State.regs[REG_D0 + DN0] == 0);
2266 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2267 PSW &= ~(PSW_Z | PSW_N | PSW_C);
2268 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2272 // 1111 1000 1100 10Dn imm8...; asr imm8,Dn (imm8 is zero-extended.)
2273 8.0xf8+4.0xc,10,2.DN0+8.IMM8:D1:::asr
2282 temp = State.regs[REG_D0 + DN0];
2285 State.regs[REG_D0 + DN0] = temp;
2286 z = (State.regs[REG_D0 + DN0] == 0);
2287 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2288 PSW &= ~(PSW_Z | PSW_N | PSW_C);
2289 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2293 // 1111 0010 1010 DmDn; lsr Dm,Dn
2294 8.0xf2+4.0xa,2.DM1,2.DN0:D0:::lsr
2302 c = State.regs[REG_D0 + DN0] & 1;
2303 State.regs[REG_D0 + DN0]
2304 >>= State.regs[REG_D0 + DM1];
2305 z = (State.regs[REG_D0 + DN0] == 0);
2306 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2307 PSW &= ~(PSW_Z | PSW_N | PSW_C);
2308 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2312 // 1111 1000 1100 01Dn imm8...; lsr imm8,Dn (imm8 is zero-extended.)
2313 8.0xf8+4.0xc,01,2.DN0+8.IMM8:D1:::lsr
2321 c = State.regs[REG_D0 + DN0] & 1;
2322 State.regs[REG_D0 + DN0] >>= IMM8;
2323 z = (State.regs[REG_D0 + DN0] == 0);
2324 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2325 PSW &= ~(PSW_Z | PSW_N | PSW_C);
2326 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2330 // 1111 0010 1001 DmDn; asl Dm,Dn
2331 8.0xf2+4.0x9,2.DM1,2.DN0:D0:::asl
2339 State.regs[REG_D0 + DN0]
2340 <<= State.regs[REG_D0 + DM1];
2341 z = (State.regs[REG_D0 + DN0] == 0);
2342 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2343 PSW &= ~(PSW_Z | PSW_N);
2344 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
2348 // 1111 1000 1100 00Dn imm8...; asl imm8,Dn (imm8 is zero-extended.)
2349 8.0xf8+4.0xc,00,2.DN0+8.IMM8:D1:::asl
2357 State.regs[REG_D0 + DN0] <<= IMM8;
2358 z = (State.regs[REG_D0 + DN0] == 0);
2359 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2360 PSW &= ~(PSW_Z | PSW_N);
2361 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
2365 // 0101 01Dn; als2 Dn
2366 4.0x5,01,2.DN0:S0:::asl2
2374 State.regs[REG_D0 + DN0] <<= 2;
2375 z = (State.regs[REG_D0 + DN0] == 0);
2376 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
2377 PSW &= ~(PSW_Z | PSW_N);
2378 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
2382 // 1111 0010 1000 01Dn; ror Dn
2383 8.0xf2+4.0x8,01,2.DN0:D0:::ror
2388 unsigned long value;
2392 value = State.regs[REG_D0 + DN0];
2396 value |= ((PSW & PSW_C) != 0) ? 0x80000000 : 0;
2397 State.regs[REG_D0 + DN0] = value;
2399 n = (value & 0x80000000) != 0;
2400 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2401 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2405 // 1111 0010 1000 00Dn; rol Dn
2406 8.0xf2+4.0x8,00,2.DN0:D0:::rol
2410 // handle ror above, too.
2412 unsigned long value;
2416 value = State.regs[REG_D0 + DN0];
2417 c = (value & 0x80000000) ? 1 : 0;
2420 value |= ((PSW & PSW_C) != 0);
2421 State.regs[REG_D0 + DN0] = value;
2423 n = (value & 0x80000000) != 0;
2424 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
2425 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0) | (c ? PSW_C : 0));
2429 // 1100 1000 d8......; beq (d8,PC) (d8 is sign-extended)
2430 8.0xc8+8.D8:S1:::beq
2438 State.regs[REG_PC] += EXTEND8 (D8);
2444 // 1100 1001 d8......; bne (d8,PC) (d8 is sign-extended)
2445 8.0xc9+8.D8:S1:::bne
2453 State.regs[REG_PC] += EXTEND8 (D8);
2459 // 1100 0001 d8......; bgt (d8,PC) (d8 is sign-extended)
2460 8.0xc1+8.D8:S1:::bgt
2467 || (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0))))
2469 State.regs[REG_PC] += EXTEND8 (D8);
2475 // 1100 0010 d8......; bge (d8,PC) (d8 is sign-extended)
2476 8.0xc2+8.D8:S1:::bge
2482 if (!(((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0)))
2484 State.regs[REG_PC] += EXTEND8 (D8);
2490 // 1100 0011 d8......; ble (d8,PC) (d8 is sign-extended)
2491 8.0xc3+8.D8:S1:::ble
2498 || (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0)))
2500 State.regs[REG_PC] += EXTEND8 (D8);
2506 // 1100 0000 d8......; blt (d8,PC) (d8 is sign-extended)
2507 8.0xc0+8.D8:S1:::blt
2513 if (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0))
2515 State.regs[REG_PC] += EXTEND8 (D8);
2521 // 1100 0101 d8......; bhi (d8,PC) (d8 is sign-extended)
2522 8.0xc5+8.D8:S1:::bhi
2528 if (!(((PSW & PSW_C) != 0) || (PSW & PSW_Z) != 0))
2530 State.regs[REG_PC] += EXTEND8 (D8);
2536 // 1100 0110 d8......; bcc (d8,PC) (d8 is sign-extended)
2537 8.0xc6+8.D8:S1:::bcc
2545 State.regs[REG_PC] += EXTEND8 (D8);
2551 // 1100 0101 d8......; bls (d8,PC) (d8 is sign-extended)
2552 8.0xc7+8.D8:S1:::bls
2558 if (((PSW & PSW_C) != 0) || (PSW & PSW_Z) != 0)
2560 State.regs[REG_PC] += EXTEND8 (D8);
2566 // 1100 0100 d8......; bcs (d8,PC) (d8 is sign-extended)
2567 8.0xc4+8.D8:S1:::bcs
2575 State.regs[REG_PC] += EXTEND8 (D8);
2581 // 1111 1000 1110 1000 d8......; bvc (d8,PC) (d8 is sign-extended)
2582 8.0xf8+8.0xe8+8.D8:D1:::bvc
2590 State.regs[REG_PC] += EXTEND8 (D8);
2596 // 1111 1000 1110 1001 d8......; bvs (d8,PC) (d8 is sign-extended)
2597 8.0xf8+8.0xe9+8.D8:D1:::bvs
2605 State.regs[REG_PC] += EXTEND8 (D8);
2611 // 1111 1000 1110 1010 d8......; bnc (d8,PC) (d8 is sign-extended)
2612 8.0xf8+8.0xea+8.D8:D1:::bnc
2620 State.regs[REG_PC] += EXTEND8 (D8);
2626 // 1111 1000 1110 1010 d8......; bns (d8,PC) (d8 is sign-extended)
2627 8.0xf8+8.0xeb+8.D8:D1:::bns
2635 State.regs[REG_PC] += EXTEND8 (D8);
2641 // 1100 1010 d8......; bra (d8,PC) (d8 is sign-extended)
2642 8.0xca+8.D8:S1:::bra
2648 State.regs[REG_PC] += EXTEND8 (D8);
2662 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2677 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2691 || (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0))))
2693 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2706 if (!(((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0)))
2708 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2722 || (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0)))
2724 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2737 if (((PSW & PSW_N) != 0) ^ ((PSW & PSW_V) != 0))
2739 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2752 if (!(((PSW & PSW_C) != 0) || (PSW & PSW_Z) != 0))
2754 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2769 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2782 if (((PSW & PSW_C) != 0) || (PSW & PSW_Z) != 0)
2784 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2799 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2812 State.regs[REG_PC] = State.regs[REG_LAR] - 4;
2824 State.regs[REG_LIR] = load_word (State.regs[REG_PC] + 1);
2825 State.regs[REG_LAR] = State.regs[REG_PC] + 5;
2829 // 1111 0000 1111 01An; jmp (An)
2830 8.0xf0+4.0xf,01,2.AN0:D0:::jmp
2835 PC = State.regs[REG_A0 + AN0];
2840 // 1100 1100 d16.....; jmp (d16,PC) (d16 is sign-extended.)
2841 8.0xcc+8.D16A+8.D16B:S2:::jmp
2846 PC = cia + EXTEND16(FETCH16(D16A, D16B));
2851 // 1101 1100 d32........; jmp (d32, PC)
2852 8.0xdc+8.D32A+8.D32B+8.D32C+8.D32D:S4:::jmp
2857 PC = cia + FETCH32(D32A, D32B, D32C, D32D);
2862 // 1100 1101 d16..... regs.... imm8....;
2863 // call (d16,PC),regs,imm8 (d16 is sign-extended., imm8 is zero-extended.)
2864 8.0xcd+8.D16A+8.D16B+8.REGS+8.IMM8:S4:::call
2869 unsigned int next_pc, sp;
2873 sp = State.regs[REG_SP];
2875 store_word(sp, next_pc);
2882 store_word (sp, State.regs[REG_D0 + 2]);
2888 store_word (sp, State.regs[REG_D0 + 3]);
2894 store_word (sp, State.regs[REG_A0 + 2]);
2900 store_word (sp, State.regs[REG_A0 + 3]);
2906 store_word (sp, State.regs[REG_D0]);
2908 store_word (sp, State.regs[REG_D0 + 1]);
2910 store_word (sp, State.regs[REG_A0]);
2912 store_word (sp, State.regs[REG_A0 + 1]);
2914 store_word (sp, State.regs[REG_MDR]);
2916 store_word (sp, State.regs[REG_LIR]);
2918 store_word (sp, State.regs[REG_LAR]);
2922 /* Update the stack pointer, note that the register saves to do not
2923 modify SP. The SP adjustment is derived totally from the imm8
2925 State.regs[REG_SP] -= IMM8;
2926 State.regs[REG_MDR] = next_pc;
2927 State.regs[REG_PC] += EXTEND16 (FETCH16(D16A, D16B));
2932 // 1101 1101 d32..... regs.... imm8....;
2933 // call (d32,PC),regs,imm8 (imm8 is zero-extended.)
2934 8.0xdd+8.D32A+8.D32B+8.D32C+8.D32D+8.REGS+8.IMM8:S6:::call
2939 unsigned int next_pc, sp;
2943 sp = State.regs[REG_SP];
2944 next_pc = State.regs[REG_PC] + 7;
2945 /* could assert that nia == next_pc here */
2946 store_word(sp, next_pc);
2947 // store_byte(sp, next_pc & 0xff);
2948 // store_byte(sp+1, (next_pc & 0xff00) >> 8 );
2949 // store_byte(sp+2, (next_pc & 0xff0000) >> 16 );
2950 // store_byte(sp+3, (next_pc & 0xff000000) >> 24);
2957 store_word (sp, State.regs[REG_D0 + 2]);
2963 store_word (sp, State.regs[REG_D0 + 3]);
2969 store_word (sp, State.regs[REG_A0 + 2]);
2975 store_word (sp, State.regs[REG_A0 + 3]);
2981 store_word (sp, State.regs[REG_D0]);
2983 store_word (sp, State.regs[REG_D0 + 1]);
2985 store_word (sp, State.regs[REG_A0]);
2987 store_word (sp, State.regs[REG_A0 + 1]);
2989 store_word (sp, State.regs[REG_MDR]);
2991 store_word (sp, State.regs[REG_LIR]);
2993 store_word (sp, State.regs[REG_LAR]);
2997 /* Update the stack pointer, note that the register saves to do not
2998 modify SP. The SP adjustment is derived totally from the imm8
3000 State.regs[REG_SP] -= IMM8;
3001 State.regs[REG_MDR] = next_pc;
3002 State.regs[REG_PC] += FETCH32(D32A, D32B, D32C, D32D);
3007 // 1111 0000 1111 00An; calls (An)
3008 8.0xf0+4.0xf,00,2.AN0:D0:::calls
3013 unsigned int next_pc, sp;
3016 sp = State.regs[REG_SP];
3017 next_pc = State.regs[REG_PC] + 2;
3018 store_word(sp, next_pc);
3019 State.regs[REG_MDR] = next_pc;
3020 State.regs[REG_PC] = State.regs[REG_A0 + AN0];
3025 // 1111 1010 1111 1111 d16.....; calls (d16,PC) (d16 is sign-extended.)
3026 8.0xfa+8.0xff+8.D16A+8.D16B:D2:::calls
3031 unsigned int next_pc, sp;
3034 sp = State.regs[REG_SP];
3035 next_pc = State.regs[REG_PC] + 4;
3036 store_word(sp, next_pc);
3037 State.regs[REG_MDR] = next_pc;
3038 State.regs[REG_PC] += EXTEND16 (FETCH16(D16A, D16B));
3043 // 1111 1100 1111 1111 d32.....; calls (d32,PC)
3044 8.0xfc+8.0xff+8.D32A+8.D32B+8.D32C+8.D32D:D4:::calls
3049 unsigned int next_pc, sp;
3052 sp = State.regs[REG_SP];
3053 next_pc = State.regs[REG_PC] + 6;
3054 store_word(sp, next_pc);
3055 State.regs[REG_MDR] = next_pc;
3056 State.regs[REG_PC] += FETCH32(D32A, D32B, D32C, D32D);
3061 // 1101 1111 regs.... imm8....; ret regs,imm8 (imm8 is zero-extended.)
3062 8.0xdf+8.REGS+8.IMM8:S2:::ret
3067 unsigned int sp, offset;
3071 State.regs[REG_SP] += IMM8;
3072 sp = State.regs[REG_SP];
3079 State.regs[REG_D0 + 2] = load_word (sp + offset);
3085 State.regs[REG_D0 + 3] = load_word (sp + offset);
3091 State.regs[REG_A0 + 2] = load_word (sp + offset);
3097 State.regs[REG_A0 + 3] = load_word (sp + offset);
3103 State.regs[REG_D0] = load_word (sp + offset);
3105 State.regs[REG_D0 + 1] = load_word (sp + offset);
3107 State.regs[REG_A0] = load_word (sp + offset);
3109 State.regs[REG_A0 + 1] = load_word (sp + offset);
3111 State.regs[REG_MDR] = load_word (sp + offset);
3113 State.regs[REG_LIR] = load_word (sp + offset);
3115 State.regs[REG_LAR] = load_word (sp + offset);
3119 /* Restore the PC value. */
3120 State.regs[REG_PC] = load_word(sp);
3125 // 1101 1110 regs.... imm8....; retf regs,imm8 (imm8 is zero-extended.)
3126 8.0xde+8.REGS+8.IMM8:S2:::retf
3131 unsigned int sp, offset;
3135 State.regs[REG_SP] += IMM8;
3136 sp = State.regs[REG_SP];
3137 State.regs[REG_PC] = State.regs[REG_MDR] - 3;
3144 State.regs[REG_D0 + 2] = load_word (sp + offset);
3150 State.regs[REG_D0 + 3] = load_word (sp + offset);
3156 State.regs[REG_A0 + 2] = load_word (sp + offset);
3162 State.regs[REG_A0 + 3] = load_word (sp + offset);
3168 State.regs[REG_D0] = load_word (sp + offset);
3170 State.regs[REG_D0 + 1] = load_word (sp + offset);
3172 State.regs[REG_A0] = load_word (sp + offset);
3174 State.regs[REG_A0 + 1] = load_word (sp + offset);
3176 State.regs[REG_MDR] = load_word (sp + offset);
3178 State.regs[REG_LIR] = load_word (sp + offset);
3180 State.regs[REG_LAR] = load_word (sp + offset);
3186 // 1111 0000 1111 1100; rets
3187 8.0xf0+8.0xfc:D0:::rets
3194 sp = State.regs[REG_SP];
3195 State.regs[REG_PC] = load_word(sp);
3200 // 1111 0000 1111 1101; rti
3201 8.0xf0+8.0xfd:D0:::rti
3208 sp = State.regs[REG_SP];
3209 PSW = load_half(sp);
3210 State.regs[REG_PC] = load_word(sp+4);
3211 State.regs[REG_SP] +=8;
3216 // 1111 0000 1111 1110; trap
3217 8.0xf0+8.0xfe:D0:::trap
3222 unsigned int sp, next_pc;
3225 sp = State.regs[REG_SP];
3226 next_pc = State.regs[REG_PC] + 2;
3227 store_word(sp, next_pc);
3232 // 1111 0000 1111 1111; rtm
3233 8.0xf0+8.0xff:D0:::rtm
3253 // 1111 0101 0000 DmDn; udf20 Dm,Dn
3254 8.0xf5+4.0x0,2.DN1,2.DN0:D0:::putx
3260 State.regs[REG_MDRQ] = State.regs[REG_D0 + DN0];
3264 // 1111 0110 1111 DmDn; udf15 Dm,Dn
3265 8.0xf6+4.0xf,2.DM1,2.DN0:D0:::getx
3273 z = (State.regs[REG_MDRQ] == 0);
3274 n = ((State.regs[REG_MDRQ] & 0x80000000) != 0);
3275 State.regs[REG_D0 + DN0] = State.regs[REG_MDRQ];
3277 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3278 PSW |= (z ? PSW_Z : 0) | (n ? PSW_N : 0);
3282 // 1111 0110 0000 DmDn; udf00 Dm,Dn
3283 8.0xf6+4.0x0,2.DM1,2.DN0:D0:::mulq
3288 unsigned long long temp;
3292 temp = ((signed64)(signed32)State.regs[REG_D0 + DN0]
3293 * (signed64)(signed32)State.regs[REG_D0 + DM1]);
3294 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3295 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3296 z = (State.regs[REG_D0 + DN0] == 0);
3297 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3298 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3299 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3303 // 1111 1001 0000 00Dn imm8....; udf00 imm8,Dn (imm8 is sign-extended.)
3304 8.0xf9+4.0x,00,2.DN0+8.IMM8:D1:::mulq
3309 unsigned long long temp;
3313 temp = ((signed64)(signed32)State.regs[REG_D0 + DN0]
3314 * (signed64)(signed32)EXTEND8 (IMM8));
3315 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3316 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3317 z = (State.regs[REG_D0 + DN0] == 0);
3318 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3319 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3320 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3324 // 1111 1011 0000 00Dn imm16...; udf00 imm16,Dn (imm16 is sign-extended.)
3325 8.0xfb+4.0x0,00,2.DN0+8.IMM16A+8.IMM16B:D2:::mulq
3330 unsigned long long temp;
3334 temp = ((signed64)(signed32)State.regs[REG_D0 + DN0]
3335 * (signed64)(signed32)EXTEND16 (FETCH16(IMM16A, IMM16B)));
3336 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3337 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3338 z = (State.regs[REG_D0 + DN0] == 0);
3339 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3340 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3341 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3345 // 1111 1101 0000 00Dn imm32...; udf00 imm32,Dn
3346 8.0xfd+4.0x0,00,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::mulq
3351 unsigned long long temp;
3355 temp = ((signed64)(signed32)State.regs[REG_D0 + DN0]
3356 * (signed64)(signed32)(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
3357 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3358 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3359 z = (State.regs[REG_D0 + DN0] == 0);
3360 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3361 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3362 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3366 // 1111 0110 0001 DmDn; udf01 Dm,Dn
3367 8.0xf6+4.0x1,2.DM1,2.DN0:D0:::mulqu
3372 unsigned long long temp;
3376 temp = ((unsigned64) State.regs[REG_D0 + DN0]
3377 * (unsigned64) State.regs[REG_D0 + DM1]);
3378 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3379 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3380 z = (State.regs[REG_D0 + DN0] == 0);
3381 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3382 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3383 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3387 // 1111 1001 0001 01Dn imm8....; udfu01 imm8,Dn (imm8 is zero-extended.)
3388 8.0xf9+4.0x1,01,2.DN0+8.IMM8:D1:::mulqu
3393 unsigned long long temp;
3397 temp = ((unsigned64)State.regs[REG_D0 + DN0]
3398 * (unsigned64)EXTEND8 (IMM8));
3399 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3400 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3401 z = (State.regs[REG_D0 + DN0] == 0);
3402 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3403 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3404 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3408 // 1111 1011 0001 01Dn imm16...; udfu01 imm16,Dn (imm16 is zero-extended.)
3409 8.0xfb+4.0x1,01,2.DN0+8.IMM16A+8.IMM16B:D2:::mulqu
3414 unsigned long long temp;
3418 temp = ((unsigned64)State.regs[REG_D0 + DN0]
3419 * (unsigned64) EXTEND16 (FETCH16(IMM16A, IMM16B)));
3420 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3421 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3422 z = (State.regs[REG_D0 + DN0] == 0);
3423 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3424 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3425 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3429 // 1111 1101 0001 01Dn imm32...; udfu01 imm32,Dn
3430 8.0xfd+4.0x1,01,2.DN0+8.IMM32A+8.IMM32B+8.IMM32C+8.IMM32D:D4:::mulqu
3435 unsigned long long temp;
3439 temp = ((unsigned64)State.regs[REG_D0 + DN0]
3440 * (unsigned64)(FETCH32(IMM32A, IMM32B, IMM32C, IMM32D)));
3441 State.regs[REG_D0 + DN0] = temp & 0xffffffff;
3442 State.regs[REG_MDRQ] = (temp & 0xffffffff00000000LL) >> 32;;
3443 z = (State.regs[REG_D0 + DN0] == 0);
3444 n = (State.regs[REG_D0 + DN0] & 0x80000000) != 0;
3445 PSW &= ~(PSW_Z | PSW_N | PSW_C | PSW_V);
3446 PSW |= ((z ? PSW_Z : 0) | (n ? PSW_N : 0));
3450 // 1111 0110 0100 DmDn; udf04 Dm,Dn
3451 8.0xf6+4.0x4,2.DM1,2.DN0:D0:::sat16
3459 temp = State.regs[REG_D0 + DM1];
3460 temp = (temp > 0x7fff ? 0x7fff : temp);
3461 temp = (temp < -0x8000 ? -0x8000 : temp);
3462 State.regs[REG_D0 + DN0] = temp;
3466 // 1111 0110 0101 DmDn; udf05 Dm,Dn
3467 8.0xf6+4.0x5,2.DM1,2.DN0:D0:::sat24
3475 temp = State.regs[REG_D0 + DM1];
3476 temp = (temp > 0x7fffff ? 0x7fffff : temp);
3477 temp = (temp < -0x800000 ? -0x800000 : temp);
3478 State.regs[REG_D0 + DN0] = temp;
3482 // 1111 0110 0111 DmDn; udf07 Dm,Dn
3483 8.0xf6+4.0x7,2.DM1,2.DN0:D0:::bsch
3491 temp = State.regs[REG_D0 + DM1];
3492 temp <<= (State.regs[REG_D0 + DN0] & 0x1f);
3493 c = (temp != 0 ? 1 : 0);
3495 PSW |= (c ? PSW_C : 0);
3499 // 1111 0000 0010 0000; syscall
3500 8.0xf0+8.0x20:D0:::syscall
3517 // State.exception = SIGTRAP;
3518 sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGTRAP);