1 #include <exec/types.h>
7 extern struct M68k CPU
;
9 ULONG
read_addressing_mode(UBYTE mode_field
, UBYTE reg_field
, UBYTE size
)
22 SHOW_OPCODE(".b D%d",reg_field
);
26 SHOW_OPCODE(".w D%d",reg_field
);
30 SHOW_OPCODE(".l D%d",reg_field
);
35 return (ULONG
) CPU
.D
[reg_field
];
39 SHOW_OPCODE(".l A%d",reg_field
);
40 return CPU
.A
[reg_field
];
48 SHOW_OPCODE(".b (A%d)",reg_field
);
49 return *(UBYTE
*)CPU
.A
[reg_field
];
53 SHOW_OPCODE(".w (A%d)",reg_field
);
54 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
58 SHOW_OPCODE(".l (A%d)",reg_field
);
59 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
69 SHOW_OPCODE(".b (A%d)+",reg_field
);
70 val
= *(UBYTE
*)CPU
.A
[reg_field
];
76 SHOW_OPCODE(".w (A%d)+",reg_field
);
77 val
= *(UWORD
*)CPU
.A
[reg_field
];
79 return SWAP_WORD(val
);
83 SHOW_OPCODE(".l (A%d)+",reg_field
);
84 val
= *(ULONG
*)CPU
.A
[reg_field
];
95 SHOW_OPCODE(".b -(A%d)",reg_field
);
97 return *(UBYTE
*)CPU
.A
[reg_field
];
101 SHOW_OPCODE(".w -(A%d)",reg_field
);
103 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
107 SHOW_OPCODE(".l -(A%d)",reg_field
);
109 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
115 case 5: /* (d16, An) */
117 LONG disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+2));
122 SHOW_OPCODE(".b (%d,A%d)",disp
,reg_field
);
123 return *(UBYTE
*)(CPU
.A
[reg_field
]+disp
);
127 SHOW_OPCODE(".w (%d,A%d)",disp
,reg_field
);
128 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
]+disp
));
132 SHOW_OPCODE(".l (%d,A%d)",disp
,reg_field
);
133 return SWAP(*(ULONG
*)(CPU
.A
[reg_field
]+disp
));
139 case 6: /* (d8, An, Xn) */
141 UBYTE reg_field2
= (*(UBYTE
*)(CPU
.PC
+2));
144 if (reg_field2
& 0x8)
145 addr
= CPU
.D
[reg_field2
>>4];
147 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
149 addr
+= (LONG
)(WORD
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.A
[reg_field
];
154 SHOW_OPCODE(".b (%d,A%d,X%d)",*(UBYTE
*)(CPU
.PC
+2),reg_field
,reg_field2
>>4);
155 return *(UBYTE
*)addr
;
159 SHOW_OPCODE(".w (%d,A%d,X%d)",*(UBYTE
*)(CPU
.PC
+2),reg_field
,reg_field2
>>4);
160 return SWAP_WORD(*(UWORD
*)addr
);
164 SHOW_OPCODE(".l (%d,A%d,X%d)",*(UBYTE
*)(CPU
.PC
+2),reg_field
,reg_field2
>>4);
165 return SWAP(*(ULONG
*)addr
);
174 case 0: /* (xxx).w */
176 val
= (ULONG
)(UWORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
180 SHOW_OPCODE(".b 0x%x",val
);
181 return (*(UBYTE
*)val
);
185 SHOW_OPCODE(".w 0x%x",val
);
186 return SWAP_WORD(*(UWORD
*)val
);
190 SHOW_OPCODE(".l 0x%x",val
);
191 return SWAP(*(ULONG
*)val
);
196 case 1: /* (xxx).l */
197 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+2));
198 SHOW_OPCODE(" 0x%x",val
);
203 SHOW_OPCODE(".b 0x%x",val
);
204 return (*(UBYTE
*)val
);
208 SHOW_OPCODE(".w 0x%x",val
);
209 return SWAP_WORD(*(UWORD
*)val
);
213 SHOW_OPCODE(".l 0x%x",val
);
214 return SWAP(*(ULONG
*)val
);
219 case 2: /* (d16, PC) */
221 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
225 SHOW_OPCODE(".b (%d,PC) [???]",val
);
226 return (ULONG
)(UBYTE
)(*(UBYTE
*)(val
+CPU
.PC
+CPU
.instsize
));
230 SHOW_OPCODE(".w (%d,PC) [???]",val
);
231 return (UWORD
)SWAP_WORD(*(UWORD
*)(val
+CPU
.PC
+CPU
.instsize
));
235 SHOW_OPCODE(".l (%d,PC) [???]",val
);
236 return SWAP(*(ULONG
*)(val
+CPU
.PC
+CPU
.instsize
));
241 case 3: /* (d8, PC, Xn) */
243 reg_field
= (*(UBYTE
*)(CPU
.PC
+2));
247 if (reg_field
& 0x08)
248 addr
= CPU
.D
[reg_field
>>4];
250 addr
= ((UWORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
252 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.PC
+2;
257 SHOW_OPCODE(".b (%d,PC,X%d)",*(BYTE
*)(CPU
.PC
+3),reg_field
);
258 return (ULONG
)(UBYTE
)(*(UBYTE
*)addr
);
262 SHOW_OPCODE(".w (%d,PC,X%d)",*(BYTE
*)(CPU
.PC
+3),reg_field
);
263 return (ULONG
)(UWORD
)SWAP_WORD(*(UWORD
*)addr
);
267 SHOW_OPCODE(".l (%d,PC,X%d)",*(BYTE
*)(CPU
.PC
+3),reg_field
);
268 return SWAP(*(ULONG
*)addr
);
274 case 4: /* <#data> */
278 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
280 SHOW_OPCODE(".b #0x%02x",val
);
285 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
287 SHOW_OPCODE(".w #0x%04x",val
);
292 val
= SWAP(*(ULONG
*)(CPU
.PC
+2));
294 SHOW_OPCODE(".l #0x%08x",val
);
304 SHOW_OPCODE("\nunrecognized! -->mode_field: %d, reg_field: %d, size : %d\n",mode_field
,reg_field
,size
);
310 ULONG
read_addressing_mode_nochange(UBYTE mode_field
, UBYTE reg_field
, UBYTE size
)
317 case 0: return (ULONG
) CPU
.D
[reg_field
];
320 case 1: return CPU
.A
[reg_field
];
327 return *(UBYTE
*)CPU
.A
[reg_field
];
331 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
335 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
345 return *(UBYTE
*)CPU
.A
[reg_field
];
349 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
353 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
362 return *(UBYTE
*)(CPU
.A
[reg_field
]-1);
366 return SWAP(*(ULONG
*)(CPU
.A
[reg_field
])-2);
370 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
])-4);
375 case 5: /* (d16, An) */
377 LONG disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+2));
381 return *(UBYTE
*)(CPU
.A
[reg_field
]+disp
);
385 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
]+disp
));
389 return SWAP(*(ULONG
*)(CPU
.A
[reg_field
]+disp
));
395 case 6: /* (d8, An, Xn) */
397 UBYTE reg_field2
= (*(UBYTE
*)(CPU
.PC
+2));
399 if (reg_field2
& 0x8)
400 addr
= CPU
.D
[reg_field2
>>4];
402 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4]);
404 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.A
[reg_field
];
409 return *(UBYTE
*)addr
;
413 return SWAP_WORD(*(UWORD
*)addr
);
417 return SWAP(*(ULONG
*)addr
);
426 case 0: /* (xxx).w */
427 val
= (ULONG
)(UWORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
431 return (*(UBYTE
*)val
);
435 return SWAP_WORD(*(UWORD
*)val
);
439 return SWAP(*(ULONG
*)val
);
444 case 1: /* (xxx).l */
445 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+2));
449 return (*(UBYTE
*)val
);
453 return SWAP_WORD(*(UWORD
*)val
);
457 return SWAP(*(ULONG
*)val
);
462 case 2: /* (d16, PC) */
463 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
467 return (ULONG
)(UBYTE
)(*(UBYTE
*)(val
+CPU
.PC
+2));
471 return (UWORD
)SWAP_WORD(*(UWORD
*)(val
+CPU
.PC
+2));
475 return SWAP(*(ULONG
*)(val
+CPU
.PC
+2));
480 case 3: /* (d8, PC, Xn) */
482 reg_field
= (*(UBYTE
*)(CPU
.PC
+2));
485 addr
= CPU
.A
[reg_field
>> 4];
487 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.A
[reg_field
>> 4])[L_WORD
];
489 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3))+ CPU
.PC
+ 2;
494 return (ULONG
)(UBYTE
)(*(UBYTE
*)addr
);
498 return (UWORD
)SWAP_WORD(*(UWORD
*)addr
);
502 return SWAP(*(ULONG
*)addr
);
508 case 4: /* <#data> */
512 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
517 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
522 val
= SWAP(*(ULONG
*)(CPU
.PC
+2));
533 SHOW_OPCODE("\nunrecognized! -->mode_field: %d, reg_field: %d\n",mode_field
,reg_field
);
538 ULONG
read_addressing_mode_offset(UBYTE mode_field
, UBYTE reg_field
, UBYTE size
)
551 SHOW_OPCODE(".b D%d",reg_field
);
555 SHOW_OPCODE(".w D%d",reg_field
);
559 SHOW_OPCODE(".l D%d",reg_field
);
564 return (ULONG
) CPU
.D
[reg_field
];
568 SHOW_OPCODE(".l A%d",reg_field
);
569 return CPU
.A
[reg_field
];
577 SHOW_OPCODE(".b (A%d)",reg_field
);
578 return *(UBYTE
*)CPU
.A
[reg_field
];
582 SHOW_OPCODE(".w (A%d)",reg_field
);
583 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
587 SHOW_OPCODE(".l (A%d)",reg_field
);
588 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
598 SHOW_OPCODE(".b (A%d)+",reg_field
);
599 val
= *(UBYTE
*)CPU
.A
[reg_field
];
605 SHOW_OPCODE(".w (A%d)+",reg_field
);
606 val
= *(UWORD
*)CPU
.A
[reg_field
];
608 return SWAP_WORD(val
);
612 SHOW_OPCODE(".l (A%d)+",reg_field
);
613 val
= *(ULONG
*)CPU
.A
[reg_field
];
624 SHOW_OPCODE(".b -(A%d)",reg_field
);
626 return *(UBYTE
*)CPU
.A
[reg_field
];
630 SHOW_OPCODE(".w -(A%d)",reg_field
);
632 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
636 SHOW_OPCODE(".l -(A%d)",reg_field
);
638 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
644 case 5: /* (d16, An) */
651 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+4));
652 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
653 return *(UBYTE
*)(CPU
.A
[reg_field
]+disp
);
657 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+4));
658 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
659 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
]+disp
));
663 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+6));
664 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
665 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]+disp
);
671 case 6: /* (d8, An, Xn) */
676 addr
= CPU
.A
[reg_field
];
681 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
683 if (reg_field2
& 0x8)
684 addr
+= CPU
.D
[reg_field2
>>4];
686 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
688 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5));
689 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4);
690 return *(UBYTE
*)addr
;
694 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
696 if (reg_field2
& 0x8)
697 addr
+= CPU
.D
[reg_field2
>>4];
699 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
701 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5));
702 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4);
703 return SWAP_WORD(*(UWORD
*)addr
);
707 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
709 if (reg_field2
& 0x8)
710 addr
+= CPU
.D
[reg_field2
>>4];
712 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
714 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+7));
715 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+7),reg_field
,reg_field2
>>4);
716 return SWAP(*(ULONG
*)addr
);
726 case 0: /* (xxx).W */
731 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
732 SHOW_OPCODE(" 0x%x",val
);
733 return *(UBYTE
*)val
;
737 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
738 SHOW_OPCODE(" 0x%x",val
);
739 return SWAP_WORD(*(UWORD
*)val
);
743 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
744 SHOW_OPCODE(" 0x%x",val
);
745 return SWAP(*(ULONG
*)val
);
750 case 1: /* (xxx).L */
755 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
756 SHOW_OPCODE(" 0x%x",val
);
757 return *(UBYTE
*)val
;
761 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
762 SHOW_OPCODE(" 0x%x",val
);
763 return SWAP_WORD(*(UWORD
*)val
);
767 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+6));
768 SHOW_OPCODE(" 0x%x",val
);
769 return SWAP(*(ULONG
*)val
);
774 case 2: /* (d16, PC) */
779 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
780 SHOW_OPCODE(".b (%d,PC) [Addresscalculation!!]",val
);
781 return (*(UBYTE
*)(val
+CPU
.PC
+6));
785 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
786 SHOW_OPCODE(".w (%d,PC) [Addresscalculation!!]",val
);
787 return SWAP_WORD(*(UWORD
*)(val
+CPU
.PC
+6));
791 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
792 SHOW_OPCODE(".l (%d,PC) [Addresscalculation!!]",val
);
793 return SWAP(*(ULONG
*)(val
+CPU
.PC
+6));
798 case 3: /* (d8, PC, Xn) */
804 reg_field
= *(UBYTE
*)(CPU
.PC
+4);
806 addr
= CPU
.D
[reg_field
>>4];
808 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
809 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + 2 + CPU
.PC
;
810 SHOW_OPCODE(".b (%d,PC,X%d) [Addresscalculation!!]",*(UBYTE
*)(CPU
.PC
+5),reg_field
>>4);
811 return (*(UBYTE
*)addr
);
815 reg_field
= *(UBYTE
*)(CPU
.PC
+4);
817 addr
= CPU
.D
[reg_field
>>4];
819 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
820 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + 2 + CPU
.PC
;
821 SHOW_OPCODE(".w (%d,PC,X%d) [Addresscalculation!!]",*(UBYTE
*)(CPU
.PC
+5),reg_field
>>4);
822 return SWAP_WORD(*(UWORD
*)addr
);
826 reg_field
= *(UBYTE
*)(CPU
.PC
+6);
828 addr
= CPU
.D
[reg_field
>>4];
830 addr
= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
831 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+7)) + 2 + CPU
.PC
;
832 SHOW_OPCODE(".w (%d,PC,X%d) [Addresscalculation!!]",*(UBYTE
*)(CPU
.PC
+7),reg_field
>>4);
833 return SWAP(*(ULONG
*)addr
);
839 case 4: /* <#data> */
843 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
845 SHOW_OPCODE(".b 0x%02x",val
);
850 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
852 SHOW_OPCODE(".w 0x%04x",val
);
857 val
= SWAP(*(ULONG
*)(CPU
.PC
+6));
859 SHOW_OPCODE(".l 0x%08x",val
);
869 SHOW_OPCODE("\nunrecognized! -->mode_field: %d, reg_field: %d, size : %d\n",mode_field
,reg_field
,size
);
875 ULONG
read_addressing_mode_nochange_offset(UBYTE mode_field
, UBYTE reg_field
, UBYTE size
)
882 case 0: return (ULONG
) CPU
.D
[reg_field
];
885 case 1: return CPU
.A
[reg_field
];
892 return *(UBYTE
*)CPU
.A
[reg_field
];
896 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
900 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
910 return *(UBYTE
*)CPU
.A
[reg_field
];
914 return SWAP_WORD(*(UWORD
*)CPU
.A
[reg_field
]);
918 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]);
927 return *(UBYTE
*)(CPU
.A
[reg_field
]-1);
931 return SWAP(*(ULONG
*)(CPU
.A
[reg_field
])-2);
935 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
])-4);
940 case 5: /* (d16, An) */
947 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+4));
948 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
949 return *(UBYTE
*)(CPU
.A
[reg_field
]+disp
);
953 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+4));
954 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
955 return SWAP_WORD(*(UWORD
*)(CPU
.A
[reg_field
]+disp
));
959 disp
= (LONG
)SWAP_WORD(*(WORD
*)(CPU
.PC
+6));
960 SHOW_OPCODE(" (%d,A%d)",disp
,reg_field
);
961 return SWAP(*(ULONG
*)CPU
.A
[reg_field
]+disp
);
967 case 6: /* (d8, An, Xn) */
971 addr
= CPU
.A
[reg_field
];
976 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5));
977 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
979 if (reg_field2
& 0x08)
980 addr
+= CPU
.D
[reg_field2
>> 4];
982 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
984 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4);
985 return *(UBYTE
*)addr
;
989 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5));
990 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
992 if (reg_field2
& 0x08)
993 addr
+= CPU
.D
[reg_field2
>> 4];
995 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
997 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4);
998 return SWAP_WORD(*(UWORD
*)addr
);
1002 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+7));
1003 reg_field2
= (*(UBYTE
*)(CPU
.PC
+6));
1005 if (reg_field2
& 0x08)
1006 addr
+= CPU
.D
[reg_field2
>> 4];
1008 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1010 SHOW_OPCODE(" (%d,A%d,X%d)",*(BYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4);
1011 return SWAP(*(ULONG
*)addr
);
1021 case 0: /* (xxx).W */
1026 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1027 SHOW_OPCODE(" 0x%x",val
);
1028 return *(UBYTE
*)val
;
1032 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1033 SHOW_OPCODE(" 0x%x",val
);
1034 return SWAP_WORD(*(UWORD
*)val
);
1038 val
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
1039 SHOW_OPCODE(" 0x%x",val
);
1040 return SWAP(*(ULONG
*)val
);
1045 case 1: /* (xxx).L */
1050 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
1051 SHOW_OPCODE(" 0x%x",val
);
1052 return *(UBYTE
*)val
;
1056 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
1057 SHOW_OPCODE(" 0x%x",val
);
1058 return SWAP_WORD(*(UWORD
*)val
);
1062 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+6));
1063 SHOW_OPCODE(" 0x%x",val
);
1064 return SWAP(*(ULONG
*)val
);
1069 case 2: /* (d16, PC) */
1074 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1075 SHOW_OPCODE(".b (%d,PC) [Addresscalculation!!]",val
);
1076 return (*(UBYTE
*)(val
+CPU
.PC
+6));
1080 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1081 SHOW_OPCODE(".w (%d,PC) [Addresscalculation!!]",val
);
1082 return SWAP_WORD(*(UWORD
*)(val
+CPU
.PC
+6));
1086 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
1087 SHOW_OPCODE(".l (%d,PC) [Addresscalculation!!]",val
);
1088 return SWAP(*(ULONG
*)(val
+CPU
.PC
+6));
1093 case 3: /* (d8, PC, Xn) */
1098 reg_field
= *(BYTE
*)(CPU
.PC
+4);
1099 if (reg_field
& 0x8)
1100 addr
= CPU
.A
[reg_field
>> 4];
1102 addr
= ((UWORD
*)&CPU
.A
[reg_field
>> 4])[L_WORD
];
1104 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + CPU
.PC
+ 2;
1106 return *(UBYTE
*)addr
;
1110 reg_field
= *(BYTE
*)(CPU
.PC
+4);
1111 if (reg_field
& 0x8)
1112 addr
= CPU
.A
[reg_field
>> 4];
1114 addr
= ((UWORD
*)&CPU
.A
[reg_field
>> 4])[L_WORD
];
1116 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + CPU
.PC
+ 2;
1118 return SWAP_WORD(*(UWORD
*)addr
);
1122 reg_field
= *(BYTE
*)(CPU
.PC
+6);
1123 if (reg_field
& 0x8)
1124 addr
= CPU
.A
[reg_field
>> 4];
1126 addr
= ((UWORD
*)&CPU
.A
[reg_field
>> 4])[L_WORD
];
1128 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+7)) + CPU
.PC
+ 2;
1130 return SWAP(*(ULONG
*)addr
);
1140 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1142 SHOW_OPCODE(".b 0x%02x",val
);
1147 val
= SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1149 SHOW_OPCODE(".w 0x%04x",val
);
1154 val
= SWAP(*(ULONG
*)(CPU
.PC
+6));
1156 SHOW_OPCODE(".l 0x%08x",val
);
1166 SHOW_OPCODE("\nunrecognized! -->mode_field: %d, reg_field: %d\n",mode_field
,reg_field
);
1172 /* LEA needs the following function */
1173 ULONG
getaddress_addressing_mode(UBYTE mode_field
, UBYTE reg_field
, UBYTE size
)
1181 case 0: /* not possible */
1184 case 1: /* not possible */
1188 SHOW_OPCODE(".l (A%d)",reg_field
);
1189 return CPU
.A
[reg_field
];
1192 case 3: /* not possible */
1195 case 4: /* not possible */
1199 case 5: /* (d16, An) */
1201 offset
= (LONG
)(WORD
)SWAP_WORD(*(WORD
*)(CPU
.PC
+2));
1202 SHOW_OPCODE(" (%d,A%d)",offset
,reg_field
);
1204 return CPU
.A
[reg_field
]+offset
;
1208 case 6: /* (d8, An, Xn) */
1210 UBYTE reg_field2
= (*(UBYTE
*)(CPU
.PC
+2));
1212 if (reg_field2
& 0x8)
1213 addr
= CPU
.D
[reg_field2
>>4];
1215 addr
= (LONG
)(WORD
)((UWORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1217 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3))+CPU
.A
[reg_field
];
1219 SHOW_OPCODE(" (%d.w,A%d,X%d) ; %x [CPU.instsize += 2??]",*(BYTE
*)(CPU
.PC
+3),reg_field
,reg_field2
>>4,addr
);
1228 case 0: /* (xxx).W */
1230 val
= (ULONG
)(UWORD
)SWAP_WORD((ULONG
)*(UWORD
*)(CPU
.PC
+2));
1231 SHOW_OPCODE(" $%x",val
);
1235 case 1: /* (xxx).L */
1237 val
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+2));
1238 SHOW_OPCODE(" $%x",val
);
1242 case 2: /* (d16, PC) */
1244 offset
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
1245 SHOW_OPCODE(" (%d.w,PC)",offset
);
1246 return CPU
.PC
+2+offset
;
1249 case 3: /* (d8, PC, Xn) */
1251 reg_field
= (*(UBYTE
*)(CPU
.PC
+2));
1255 if (reg_field
& 0x8)
1256 addr
= CPU
.D
[reg_field
>>4];
1258 addr
= ((UWORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
1260 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.PC
+ 2;
1266 SHOW_OPCODE(".b (%d,PC,X%d)",val
,reg_field
>>4);
1270 SHOW_OPCODE(".w (%d,PC,X%d)",val
,reg_field
>>4);
1274 SHOW_OPCODE(".l (%d,PC,X%d)",val
,reg_field
>>4);
1287 SHOW_OPCODE("\nunrecognized! -->mode_field: %d, reg_field: %d, size : %d\n",mode_field
,reg_field
,size
);
1294 VOID
write_addressing_mode(UBYTE mode_field
, UBYTE reg_field
, ULONG val
, UBYTE size
)
1304 SHOW_OPCODE("D%d",reg_field
);
1305 (((BYTE
*)&CPU
.D
[reg_field
]))[L_BYTE
] = (UBYTE
)val
;
1309 SHOW_OPCODE("D%d",reg_field
);
1310 (((WORD
*)&CPU
.D
[reg_field
]))[L_WORD
] = (UWORD
)val
;
1314 SHOW_OPCODE("D%d",reg_field
);
1315 (LONG
)CPU
.D
[reg_field
] = (ULONG
)val
;
1321 case 1: CPU
.A
[reg_field
] = val
;
1322 SHOW_OPCODE("A%d",reg_field
);
1327 SHOW_OPCODE("(A%d)",reg_field
);
1331 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1336 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1341 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1348 SHOW_OPCODE("(A%d)+",reg_field
);
1352 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1353 CPU
.A
[reg_field
]+=1;
1358 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1359 CPU
.A
[reg_field
]+=2;
1364 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1365 CPU
.A
[reg_field
]+=4;
1372 SHOW_OPCODE("-(A%d)",reg_field
);
1376 CPU
.A
[reg_field
]-=1;
1377 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1382 CPU
.A
[reg_field
]-=2;
1383 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1388 CPU
.A
[reg_field
]-=4;
1389 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1395 case 5: /* (d16, An) */
1397 offset
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
1401 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1402 *(UBYTE
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (UBYTE
)val
;
1407 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1408 *(UWORD
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (UWORD
)SWAP_WORD(val
);
1413 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1414 *(ULONG
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (ULONG
)SWAP(val
);
1420 case 6: /* (d8, An, Dn) */
1422 UBYTE reg_field2
= (*(UBYTE
*)(CPU
.PC
+2));
1425 if (reg_field2
& 0x8)
1426 addr
= CPU
.D
[reg_field2
>>4];
1428 addr
= (LONG
)(WORD
)((UWORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1430 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.A
[reg_field
];
1435 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(BYTE
*)(CPU
.PC
+3),reg_field
,reg_field2
>>4,addr
);
1436 *(UBYTE
*)addr
= (UBYTE
)val
;
1441 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(BYTE
*)(CPU
.PC
+3),reg_field
,reg_field2
>>4,addr
);
1442 *(UWORD
*)addr
= (UWORD
)SWAP_WORD(val
);
1447 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(BYTE
*)(CPU
.PC
+3),reg_field
,reg_field2
>>4,addr
);
1448 *(ULONG
*)addr
= (ULONG
)SWAP(val
);
1458 case 0: /* (xxx).W */
1459 addr
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
1460 SHOW_OPCODE("$%x",addr
);
1465 *(UBYTE
*)addr
= val
;
1470 *(UWORD
*)addr
= SWAP_WORD(val
);
1475 *(ULONG
*)addr
= SWAP(val
);
1481 case 1: /* (xxx).L */
1482 addr
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+2));
1483 SHOW_OPCODE("$%x",addr
);
1488 *(UBYTE
*)addr
= val
;
1493 *(UWORD
*)addr
= SWAP_WORD(val
);
1498 *(ULONG
*)addr
= SWAP(val
);
1504 case 2: /* (d16, PC) */
1505 addr
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+2));
1507 SHOW_OPCODE("(%d.w, PC) ; $%x [???]",SWAP_WORD(*(UWORD
*)(CPU
.PC
+2)),addr
);
1512 *(UBYTE
*)addr
= val
;
1517 *(UWORD
*)addr
= SWAP_WORD(val
);
1522 *(ULONG
*)addr
= SWAP(val
);
1528 case 3: /* (d8, PC, Xn) */
1530 reg_field
= (*(UBYTE
*)(CPU
.PC
+2));
1532 if (reg_field
& 0x08)
1533 addr
= CPU
.D
[reg_field
>>4];
1535 addr
= (LONG
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
1537 addr
+= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+3)) + CPU
.PC
+ 2;
1544 *(UBYTE
*)addr
= val
;
1549 *(UWORD
*)addr
= SWAP_WORD(val
);
1554 *(ULONG
*)addr
= SWAP(val
);
1566 kprintf("Unknow addressing mode for writing data!\n");
1569 VOID
write_addressing_mode_offset(UBYTE mode_field
, UBYTE reg_field
, ULONG val
, UBYTE size
)
1579 SHOW_OPCODE("D%d",reg_field
);
1580 (((BYTE
*)&CPU
.D
[reg_field
]))[L_BYTE
] = (UBYTE
)val
;
1584 SHOW_OPCODE("D%d",reg_field
);
1585 (((WORD
*)&CPU
.D
[reg_field
]))[L_WORD
] = (UWORD
)val
;
1589 SHOW_OPCODE("D%d",reg_field
);
1590 (LONG
)CPU
.D
[reg_field
] = (ULONG
)val
;
1596 case 1: CPU
.A
[reg_field
] = val
;
1597 SHOW_OPCODE("A%d",reg_field
);
1602 SHOW_OPCODE("(A%d)",reg_field
);
1606 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1611 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1616 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1623 SHOW_OPCODE("(A%d)+",reg_field
);
1627 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1628 CPU
.A
[reg_field
]+=1;
1633 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1634 CPU
.A
[reg_field
]+=2;
1639 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1640 CPU
.A
[reg_field
]+=4;
1647 SHOW_OPCODE("-(A%d)",reg_field
);
1651 CPU
.A
[reg_field
]-=1;
1652 *(UBYTE
*)CPU
.A
[reg_field
] = val
;
1657 CPU
.A
[reg_field
]-=2;
1658 *(UWORD
*)CPU
.A
[reg_field
] = SWAP_WORD(val
);
1663 CPU
.A
[reg_field
]-=4;
1664 *(ULONG
*)CPU
.A
[reg_field
] = SWAP(val
);
1670 case 5: /* (d16, An) */
1675 offset
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1676 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1677 *(UBYTE
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (UBYTE
)val
;
1682 offset
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1683 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1684 *(UWORD
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (UWORD
)SWAP_WORD(val
);
1689 offset
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
1690 SHOW_OPCODE("%x(A%d) ; %x\n",offset
,reg_field
,CPU
.A
[reg_field
]+(LONG
)offset
);
1691 *(ULONG
*)(CPU
.A
[reg_field
]+(LONG
)offset
) = (ULONG
)SWAP(val
);
1697 case 6: /* (d8, An, Xn) */
1702 addr
= CPU
.A
[reg_field
];
1707 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
1709 if (reg_field2
& 0x8)
1710 addr
+= CPU
.D
[reg_field2
>>4];
1712 addr
+= (LONG
)(WORD
)((UWORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1714 addr
+= (LONG
)(WORD
)(BYTE
)(*(UBYTE
*)(CPU
.PC
+5));
1715 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(UBYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4,addr
);
1716 *(UBYTE
*)addr
= (UBYTE
)val
;
1721 reg_field2
= (*(UBYTE
*)(CPU
.PC
+4));
1723 if (reg_field2
& 0x8)
1724 addr
+= CPU
.D
[reg_field2
>>4];
1726 addr
+= (LONG
)(WORD
)((UWORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1728 addr
+= (LONG
)(WORD
)(BYTE
)(*(UBYTE
*)(CPU
.PC
+5));
1729 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(UBYTE
*)(CPU
.PC
+5),reg_field
,reg_field2
>>4,addr
);
1730 *(UWORD
*)addr
= (UWORD
)SWAP_WORD(val
);
1735 reg_field2
= (*(UBYTE
*)(CPU
.PC
+6));
1737 if (reg_field2
& 0x8)
1738 addr
+= CPU
.D
[reg_field2
>>4];
1740 addr
+= (LONG
)(WORD
)((UWORD
*)&CPU
.D
[reg_field2
>>4])[L_WORD
];
1742 addr
+= (LONG
)(WORD
)(BYTE
)(*(UBYTE
*)(CPU
.PC
+7));
1743 SHOW_OPCODE("%x(A%d,X%d) ; %x\n",*(UBYTE
*)(CPU
.PC
+7),reg_field
,reg_field2
>>4,addr
);
1744 *(ULONG
*)addr
= (ULONG
)SWAP(val
);
1754 case 0: /* (xxx).W */
1759 addr
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1760 SHOW_OPCODE("$%x.w",addr
);
1761 *(UBYTE
*)addr
= val
;
1766 addr
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1767 SHOW_OPCODE("$%x.w",addr
);
1768 *(UWORD
*)addr
= SWAP_WORD(val
);
1773 addr
= (ULONG
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
1774 SHOW_OPCODE("$%x.w",addr
);
1775 *(ULONG
*)addr
= SWAP(val
);
1781 case 1: /* (xxx).L */
1786 addr
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
1787 SHOW_OPCODE("$%x.l",addr
);
1788 *(UBYTE
*)addr
= val
;
1793 addr
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+4));
1794 SHOW_OPCODE("$%x.l",addr
);
1795 *(UWORD
*)addr
= SWAP_WORD(val
);
1800 addr
= (ULONG
)SWAP(*(ULONG
*)(CPU
.PC
+6));
1801 SHOW_OPCODE("$%x.l",addr
);
1802 *(ULONG
*)addr
= SWAP(val
);
1808 case 2: /* (d16, PC) */
1813 addr
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1815 SHOW_OPCODE("(%d.w, PC) ; $%x [???]",SWAP_WORD(*(UWORD
*)(CPU
.PC
+2)),addr
);
1816 *(UBYTE
*)addr
= val
;
1821 addr
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+4));
1823 SHOW_OPCODE("(%d.w, PC) ; $%x [???]",SWAP_WORD(*(UWORD
*)(CPU
.PC
+2)),addr
);
1824 *(UWORD
*)addr
= SWAP_WORD(val
);
1829 addr
= (LONG
)(WORD
)SWAP_WORD(*(UWORD
*)(CPU
.PC
+6));
1831 SHOW_OPCODE("(%d.w, PC) ; $%x [???]",SWAP_WORD(*(UWORD
*)(CPU
.PC
+2)),addr
);
1832 *(ULONG
*)addr
= SWAP(val
);
1838 case 3: /* (d8, PC, Xn) */
1843 reg_field
= (*(UBYTE
*)(CPU
.PC
+4));
1844 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + CPU
.PC
+ 2;
1847 addr
+= CPU
.D
[reg_field
>>4];
1848 SHOW_OPCODE("(%d.w,PC,X%d.l) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+5)),reg_field
>>4,addr
);
1852 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
1853 SHOW_OPCODE("(%d.w,PC,X%d.w) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+5)),reg_field
>>4,addr
);
1855 *(UBYTE
*)addr
= val
;
1860 reg_field
= (*(BYTE
*)(CPU
.PC
+4));
1861 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+5)) + CPU
.PC
+ 2;
1864 addr
+= CPU
.D
[reg_field
>>4];
1865 SHOW_OPCODE("(%d.w,PC,X%d.l) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+5)),reg_field
>>4,addr
);
1869 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
1870 SHOW_OPCODE("(%d.w,PC,X%d.w) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+5)),reg_field
>>4,addr
);
1872 *(UWORD
*)addr
= SWAP_WORD(val
);
1877 reg_field
= (*(BYTE
*)(CPU
.PC
+6));
1878 addr
= (LONG
)(WORD
)(BYTE
)(*(BYTE
*)(CPU
.PC
+7)) + CPU
.PC
+ 2;
1881 addr
+= CPU
.D
[reg_field
>>4];
1882 SHOW_OPCODE("(%d.w,PC,X%d.l) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+7)),reg_field
>>4,addr
);
1886 addr
+= (LONG
)(WORD
)((WORD
*)&CPU
.D
[reg_field
>>4])[L_WORD
];
1887 SHOW_OPCODE("(%d.w,PC,X%d.w) ; $%x [???]",(*(UBYTE
*)(CPU
.PC
+7)),reg_field
>>4,addr
);
1889 *(ULONG
*)addr
= SWAP(val
);
1897 kprintf("Unknow addressing mode for writing data!\n");