2 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
3 // Copyright (C) 1999-2003 Forgotten
4 // Copyright (C) 2005-2006 Forgotten and the VBA development team
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or(at your option)
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #define CONSOLE_OUTPUT(a,b) \
22 extern void (*dbgOutput)(char *, u32);\
23 if((opcode == 0xe0000000) && (reg[0].I == 0xC0DED00D)) {\
27 #define CONSOLE_OUTPUT(a,b)
31 reg[dest].I = reg[(opcode>>16)&15].I & value;\
32 CONSOLE_OUTPUT(NULL,reg[2].I);
35 reg[dest].I = reg[(opcode>>16)&15].I & value;\
37 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
38 Z_FLAG = (reg[dest].I) ? false : true;\
42 reg[dest].I = reg[(opcode>>16)&15].I ^ value;
45 reg[dest].I = reg[(opcode>>16)&15].I ^ value;\
47 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
48 Z_FLAG = (reg[dest].I) ? false : true;\
51 #define NEG(i) ((i) >> 31)
52 #define POS(i) ((~(i)) >> 31)
53 #define ADDCARRY(a, b, c) \
54 C_FLAG = ((NEG(a) & NEG(b)) |\
56 (NEG(b) & POS(c))) ? true : false;
57 #define ADDOVERFLOW(a, b, c) \
58 V_FLAG = ((NEG(a) & NEG(b) & POS(c)) |\
59 (POS(a) & POS(b) & NEG(c))) ? true : false;
60 #define SUBCARRY(a, b, c) \
61 C_FLAG = ((NEG(a) & POS(b)) |\
63 (POS(b) & POS(c))) ? true : false;
64 #define SUBOVERFLOW(a, b, c)\
65 V_FLAG = ((NEG(a) & POS(b) & POS(c)) |\
66 (POS(a) & NEG(b) & NEG(c))) ? true : false;
69 reg[dest].I = reg[base].I - value;\
73 u32 lhs = reg[base].I;\
77 Z_FLAG = (res == 0) ? true : false;\
78 N_FLAG = NEG(res) ? true : false;\
79 SUBCARRY(lhs, rhs, res);\
80 SUBOVERFLOW(lhs, rhs, res);\
84 reg[dest].I = value - reg[base].I;\
88 u32 lhs = reg[base].I;\
92 Z_FLAG = (res == 0) ? true : false;\
93 N_FLAG = NEG(res) ? true : false;\
94 SUBCARRY(rhs, lhs, res);\
95 SUBOVERFLOW(rhs, lhs, res);\
99 reg[dest].I = reg[base].I + value;\
103 u32 lhs = reg[base].I;\
105 u32 res = lhs + rhs;\
107 Z_FLAG = (res == 0) ? true : false;\
108 N_FLAG = NEG(res) ? true : false;\
109 ADDCARRY(lhs, rhs, res);\
110 ADDOVERFLOW(lhs, rhs, res);\
114 reg[dest].I = reg[base].I + value + (u32)C_FLAG;\
118 u32 lhs = reg[base].I;\
120 u32 res = lhs + rhs + (u32)C_FLAG;\
122 Z_FLAG = (res == 0) ? true : false;\
123 N_FLAG = NEG(res) ? true : false;\
124 ADDCARRY(lhs, rhs, res);\
125 ADDOVERFLOW(lhs, rhs, res);\
129 reg[dest].I = reg[base].I - value - !((u32)C_FLAG);\
133 u32 lhs = reg[base].I;\
135 u32 res = lhs - rhs - !((u32)C_FLAG);\
137 Z_FLAG = (res == 0) ? true : false;\
138 N_FLAG = NEG(res) ? true : false;\
139 SUBCARRY(lhs, rhs, res);\
140 SUBOVERFLOW(lhs, rhs, res);\
144 reg[dest].I = value - reg[base].I - !((u32)C_FLAG);\
148 u32 lhs = reg[base].I;\
150 u32 res = rhs - lhs - !((u32)C_FLAG);\
152 Z_FLAG = (res == 0) ? true : false;\
153 N_FLAG = NEG(res) ? true : false;\
154 SUBCARRY(rhs, lhs, res);\
155 SUBOVERFLOW(rhs, lhs, res);\
159 u32 lhs = reg[base].I;\
161 u32 res = lhs - rhs;\
162 Z_FLAG = (res == 0) ? true : false;\
163 N_FLAG = NEG(res) ? true : false;\
164 SUBCARRY(lhs, rhs, res);\
165 SUBOVERFLOW(lhs, rhs, res);\
169 u32 lhs = reg[base].I;\
171 u32 res = lhs + rhs;\
172 Z_FLAG = (res == 0) ? true : false;\
173 N_FLAG = NEG(res) ? true : false;\
174 ADDCARRY(lhs, rhs, res);\
175 ADDOVERFLOW(lhs, rhs, res);\
178 #define LOGICAL_LSL_REG \
180 u32 v = reg[opcode & 0x0f].I;\
181 C_OUT = (v >> (32 - shift)) & 1 ? true : false;\
184 #define LOGICAL_LSR_REG \
186 u32 v = reg[opcode & 0x0f].I;\
187 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
190 #define LOGICAL_ASR_REG \
192 u32 v = reg[opcode & 0x0f].I;\
193 C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false;\
194 value = (s32)v >> (int)shift;\
196 #define LOGICAL_ROR_REG \
198 u32 v = reg[opcode & 0x0f].I;\
199 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
200 value = ((v << (32 - shift)) |\
203 #define LOGICAL_RRX_REG \
205 u32 v = reg[opcode & 0x0f].I;\
206 shift = (int)C_FLAG;\
207 C_OUT = (v & 1) ? true : false;\
211 #define LOGICAL_ROR_IMM \
213 u32 v = opcode & 0xff;\
214 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
215 value = ((v << (32 - shift)) |\
218 #define ARITHMETIC_LSL_REG \
220 u32 v = reg[opcode & 0x0f].I;\
223 #define ARITHMETIC_LSR_REG \
225 u32 v = reg[opcode & 0x0f].I;\
228 #define ARITHMETIC_ASR_REG \
230 u32 v = reg[opcode & 0x0f].I;\
231 value = (s32)v >> (int)shift;\
233 #define ARITHMETIC_ROR_REG \
235 u32 v = reg[opcode & 0x0f].I;\
236 value = ((v << (32 - shift)) |\
239 #define ARITHMETIC_RRX_REG \
241 u32 v = reg[opcode & 0x0f].I;\
242 shift = (int)C_FLAG;\
246 #define ARITHMETIC_ROR_IMM \
248 u32 v = opcode & 0xff;\
249 value = ((v << (32 - shift)) |\
252 #define ROR_IMM_MSR \
254 u32 v = opcode & 0xff;\
255 value = ((v << (32 - shift)) |\
260 value = ((value << (32 - shift)) |\
265 shift = (int)C_FLAG;\
266 value = ((value >> 1) |\
274 reg[dest].I = reg[base].I - value;\
278 register int Flags; \
279 register int Result; \
280 asm volatile("subco. %0, %2, %3\n" \
285 : "r" (reg[base].I), \
288 reg[dest].I = Result; \
289 Z_FLAG = (Flags >> 29) & 1; \
290 N_FLAG = (Flags >> 31) & 1; \
291 C_FLAG = (Flags >> 25) & 1; \
292 V_FLAG = (Flags >> 26) & 1; \
296 reg[dest].I = value - reg[base].I;\
300 register int Flags; \
301 register int Result; \
302 asm volatile("subfco. %0, %2, %3\n" \
307 : "r" (reg[base].I), \
310 reg[dest].I = Result; \
311 Z_FLAG = (Flags >> 29) & 1; \
312 N_FLAG = (Flags >> 31) & 1; \
313 C_FLAG = (Flags >> 25) & 1; \
314 V_FLAG = (Flags >> 26) & 1; \
318 reg[dest].I = reg[base].I + value;\
323 register int Flags; \
324 register int Result; \
325 asm volatile("addco. %0, %2, %3\n" \
330 : "r" (reg[base].I), \
333 reg[dest].I = Result; \
334 Z_FLAG = (Flags >> 29) & 1; \
335 N_FLAG = (Flags >> 31) & 1; \
336 C_FLAG = (Flags >> 25) & 1; \
337 V_FLAG = (Flags >> 26) & 1; \
341 reg[dest].I = reg[base].I + value + (u32)C_FLAG;\
345 register int Flags; \
346 register int Result; \
347 asm volatile("mtspr xer, %4\n" \
348 "addeo. %0, %2, %3\n" \
353 : "r" (reg[base].I), \
357 reg[dest].I = Result; \
358 Z_FLAG = (Flags >> 29) & 1; \
359 N_FLAG = (Flags >> 31) & 1; \
360 C_FLAG = (Flags >> 25) & 1; \
361 V_FLAG = (Flags >> 26) & 1; \
365 reg[dest].I = reg[base].I - value - (C_FLAG^1);\
369 register int Flags; \
370 register int Result; \
371 asm volatile("mtspr xer, %4\n" \
372 "subfeo. %0, %3, %2\n" \
377 : "r" (reg[base].I), \
381 reg[dest].I = Result; \
382 Z_FLAG = (Flags >> 29) & 1; \
383 N_FLAG = (Flags >> 31) & 1; \
384 C_FLAG = (Flags >> 25) & 1; \
385 V_FLAG = (Flags >> 26) & 1; \
389 reg[dest].I = value - reg[base].I - (C_FLAG^1);\
393 register int Flags; \
394 register int Result; \
395 asm volatile("mtspr xer, %4\n" \
396 "subfeo. %0, %2, %3\n" \
401 : "r" (reg[base].I), \
405 reg[dest].I = Result; \
406 Z_FLAG = (Flags >> 29) & 1; \
407 N_FLAG = (Flags >> 31) & 1; \
408 C_FLAG = (Flags >> 25) & 1; \
409 V_FLAG = (Flags >> 26) & 1; \
413 register int Flags; \
414 register int Result; \
415 asm volatile("subco. %0, %2, %3\n" \
420 : "r" (reg[base].I), \
423 Z_FLAG = (Flags >> 29) & 1; \
424 N_FLAG = (Flags >> 31) & 1; \
425 C_FLAG = (Flags >> 25) & 1; \
426 V_FLAG = (Flags >> 26) & 1; \
430 register int Flags; \
431 register int Result; \
432 asm volatile("addco. %0, %2, %3\n" \
437 : "r" (reg[base].I), \
440 Z_FLAG = (Flags >> 29) & 1; \
441 N_FLAG = (Flags >> 31) & 1; \
442 C_FLAG = (Flags >> 25) & 1; \
443 V_FLAG = (Flags >> 26) & 1; \
446 #define LOGICAL_LSL_REG \
448 u32 v = reg[opcode & 0x0f].I;\
449 C_OUT = (v >> (32 - shift)) & 1 ? true : false;\
452 #define LOGICAL_LSR_REG \
454 u32 v = reg[opcode & 0x0f].I;\
455 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
458 #define LOGICAL_ASR_REG \
460 u32 v = reg[opcode & 0x0f].I;\
461 C_OUT = ((s32)v >> (int)(shift - 1)) & 1 ? true : false;\
462 value = (s32)v >> (int)shift;\
464 #define LOGICAL_ROR_REG \
466 u32 v = reg[opcode & 0x0f].I;\
467 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
468 value = ((v << (32 - shift)) |\
471 #define LOGICAL_RRX_REG \
473 u32 v = reg[opcode & 0x0f].I;\
474 shift = (int)C_FLAG;\
475 C_OUT = (v & 1) ? true : false;\
479 #define LOGICAL_ROR_IMM \
481 u32 v = opcode & 0xff;\
482 C_OUT = (v >> (shift - 1)) & 1 ? true : false;\
483 value = ((v << (32 - shift)) |\
486 #define ARITHMETIC_LSL_REG \
488 u32 v = reg[opcode & 0x0f].I;\
491 #define ARITHMETIC_LSR_REG \
493 u32 v = reg[opcode & 0x0f].I;\
496 #define ARITHMETIC_ASR_REG \
498 u32 v = reg[opcode & 0x0f].I;\
499 value = (s32)v >> (int)shift;\
501 #define ARITHMETIC_ROR_REG \
503 u32 v = reg[opcode & 0x0f].I;\
504 value = ((v << (32 - shift)) |\
507 #define ARITHMETIC_RRX_REG \
509 u32 v = reg[opcode & 0x0f].I;\
510 shift = (int)C_FLAG;\
514 #define ARITHMETIC_ROR_IMM \
516 u32 v = opcode & 0xff;\
517 value = ((v << (32 - shift)) |\
520 #define ROR_IMM_MSR \
522 u32 v = opcode & 0xff;\
523 value = ((v << (32 - shift)) |\
528 value = ((value << (32 - shift)) |\
533 shift = (int)C_FLAG;\
534 value = ((value >> 1) |\
539 asm ("sub %1, %%ebx;"\
540 : "=b" (reg[dest].I)\
541 : "r" (value), "b" (reg[base].I));
544 asm ("sub %1, %%ebx;"\
549 : "=b" (reg[dest].I)\
550 : "r" (value), "b" (reg[base].I));
553 asm ("sub %1, %%ebx;"\
554 : "=b" (reg[dest].I)\
555 : "r" (reg[base].I), "b" (value));
558 asm ("sub %1, %%ebx;"\
563 : "=b" (reg[dest].I)\
564 : "r" (reg[base].I), "b" (value));
567 asm ("add %1, %%ebx;"\
568 : "=b" (reg[dest].I)\
569 : "r" (value), "b" (reg[base].I));
572 asm ("add %1, %%ebx;"\
577 : "=b" (reg[dest].I)\
578 : "r" (value), "b" (reg[base].I));
581 asm ("bt $0, C_FLAG;"\
583 : "=b" (reg[dest].I)\
584 : "r" (value), "b" (reg[base].I));
587 asm ("bt $0, C_FLAG;"\
593 : "=b" (reg[dest].I)\
594 : "r" (value), "b" (reg[base].I));
597 asm ("bt $0, C_FLAG;"\
600 : "=b" (reg[dest].I)\
601 : "r" (value), "b" (reg[base].I));
604 asm ("bt $0, C_FLAG;"\
611 : "=b" (reg[dest].I)\
612 : "r" (value), "b" (reg[base].I));
614 asm ("bt $0, C_FLAG;"\
617 : "=b" (reg[dest].I)\
618 : "r" (reg[base].I), "b" (value));
621 asm ("bt $0, C_FLAG;"\
628 : "=b" (reg[dest].I)\
629 : "r" (reg[base].I), "b" (value));
637 : "r" (value), "r" (reg[base].I));
646 : "r" (value), "r" (reg[base].I));
647 #define LOGICAL_LSL_REG \
648 asm("shl %%cl, %%eax;"\
650 : "=a" (value), "=c" (C_OUT)\
651 : "a" (reg[opcode & 0x0f].I), "c" (shift));
653 #define LOGICAL_LSR_REG \
654 asm("shr %%cl, %%eax;"\
656 : "=a" (value), "=c" (C_OUT)\
657 : "a" (reg[opcode & 0x0f].I), "c" (shift));
659 #define LOGICAL_ASR_REG \
660 asm("sar %%cl, %%eax;"\
662 : "=a" (value), "=c" (C_OUT)\
663 : "a" (reg[opcode & 0x0f].I), "c" (shift));
665 #define LOGICAL_ROR_REG \
666 asm("ror %%cl, %%eax;"\
668 : "=a" (value), "=c" (C_OUT)\
669 : "a" (reg[opcode & 0x0f].I), "c" (shift));
671 #define LOGICAL_RRX_REG \
672 asm("bt $0, C_FLAG;"\
675 : "=a" (value), "=c" (C_OUT)\
676 : "a" (reg[opcode & 0x0f].I));
678 #define LOGICAL_ROR_IMM \
679 asm("ror %%cl, %%eax;"\
681 : "=a" (value), "=c" (C_OUT)\
682 : "a" (opcode & 0xff), "c" (shift));
683 #define ARITHMETIC_LSL_REG \
687 : "a" (reg[opcode & 0x0f].I), "c" (shift));
689 #define ARITHMETIC_LSR_REG \
693 : "a" (reg[opcode & 0x0f].I), "c" (shift));
695 #define ARITHMETIC_ASR_REG \
699 : "a" (reg[opcode & 0x0f].I), "c" (shift));
701 #define ARITHMETIC_ROR_REG \
705 : "a" (reg[opcode & 0x0f].I), "c" (shift));
707 #define ARITHMETIC_RRX_REG \
712 : "a" (reg[opcode & 0x0f].I));
714 #define ARITHMETIC_ROR_IMM \
718 : "a" (opcode & 0xff), "c" (shift));
719 #define ROR_IMM_MSR \
720 asm ("ror %%cl, %%eax;"\
722 : "a" (opcode & 0xFF), "c" (shift));
726 : "r" (value), "c" (shift));
728 asm("bt $0, C_FLAG;"\
737 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
738 __asm sub ebx, value\
740 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
746 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
747 __asm sub ebx, value\
749 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
750 __asm sets byte ptr N_FLAG\
751 __asm setz byte ptr Z_FLAG\
752 __asm setnc byte ptr C_FLAG\
753 __asm seto byte ptr V_FLAG\
759 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
760 __asm mov eax, value\
763 __asm mov dword ptr [OFFSET reg+4*ebx], eax\
769 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
770 __asm mov eax, value\
773 __asm mov dword ptr [OFFSET reg+4*ebx], eax\
774 __asm sets byte ptr N_FLAG\
775 __asm setz byte ptr Z_FLAG\
776 __asm setnc byte ptr C_FLAG\
777 __asm seto byte ptr V_FLAG\
783 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
784 __asm add ebx, value\
786 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
792 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
793 __asm add ebx, value\
795 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
796 __asm sets byte ptr N_FLAG\
797 __asm setz byte ptr Z_FLAG\
798 __asm setc byte ptr C_FLAG\
799 __asm seto byte ptr V_FLAG\
805 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
806 __asm bt word ptr C_FLAG, 0\
807 __asm adc ebx, value\
809 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
815 __asm mov ebx, dword ptr [OFFSET reg+4*ebx]\
816 __asm bt word ptr C_FLAG, 0\
817 __asm adc ebx, value\
819 __asm mov dword ptr [OFFSET reg+4*eax], ebx\
820 __asm sets byte ptr N_FLAG\
821 __asm setz byte ptr Z_FLAG\
822 __asm setc byte ptr C_FLAG\
823 __asm seto byte ptr V_FLAG\
829 __asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\
830 __asm mov eax, value\
831 __asm bt word ptr C_FLAG, 0\
835 __asm mov dword ptr [OFFSET reg + 4*eax], ebx\
841 __asm mov ebx, dword ptr [OFFSET reg + 4*ebx]\
842 __asm mov eax, value\
843 __asm bt word ptr C_FLAG, 0\
847 __asm mov dword ptr [OFFSET reg + 4*eax], ebx\
848 __asm sets byte ptr N_FLAG\
849 __asm setz byte ptr Z_FLAG\
850 __asm setnc byte ptr C_FLAG\
851 __asm seto byte ptr V_FLAG\
855 __asm mov ebx, value\
857 __asm mov eax, dword ptr[OFFSET reg + 4*eax]\
858 __asm bt word ptr C_FLAG, 0\
862 __asm mov dword ptr [OFFSET reg + 4*eax], ebx\
867 __asm mov ebx, value\
869 __asm mov eax, dword ptr[OFFSET reg + 4*eax]\
870 __asm bt word ptr C_FLAG, 0\
874 __asm mov dword ptr [OFFSET reg + 4*eax], ebx\
875 __asm sets byte ptr N_FLAG\
876 __asm setz byte ptr Z_FLAG\
877 __asm setnc byte ptr C_FLAG\
878 __asm seto byte ptr V_FLAG\
883 __asm mov ebx, dword ptr [OFFSET reg+4*eax]\
884 __asm sub ebx, value\
885 __asm sets byte ptr N_FLAG\
886 __asm setz byte ptr Z_FLAG\
887 __asm setnc byte ptr C_FLAG\
888 __asm seto byte ptr V_FLAG\
894 __asm mov ebx, dword ptr [OFFSET reg+4*eax]\
895 __asm add ebx, value\
896 __asm sets byte ptr N_FLAG\
897 __asm setz byte ptr Z_FLAG\
898 __asm setc byte ptr C_FLAG\
899 __asm seto byte ptr V_FLAG\
901 #define LOGICAL_LSL_REG \
902 __asm mov eax, opcode\
904 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
905 __asm mov cl, byte ptr shift\
907 __asm mov value, eax\
908 __asm setc byte ptr C_OUT
910 #define LOGICAL_LSR_REG \
911 __asm mov eax, opcode\
913 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
914 __asm mov cl, byte ptr shift\
916 __asm mov value, eax\
917 __asm setc byte ptr C_OUT
919 #define LOGICAL_ASR_REG \
920 __asm mov eax, opcode\
922 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
923 __asm mov cl, byte ptr shift\
925 __asm mov value, eax\
926 __asm setc byte ptr C_OUT
928 #define LOGICAL_ROR_REG \
929 __asm mov eax, opcode\
931 __asm mov eax, dword ptr [OFFSET reg + 4*eax]\
932 __asm mov cl, byte ptr shift\
934 __asm mov value, eax\
935 __asm setc byte ptr C_OUT
937 #define LOGICAL_RRX_REG \
938 __asm mov eax, opcode\
940 __asm mov eax, dword ptr [OFFSET reg + 4*eax]\
941 __asm bt word ptr C_OUT, 0\
943 __asm mov value, eax\
944 __asm setc byte ptr C_OUT
946 #define LOGICAL_ROR_IMM \
947 __asm mov eax, opcode\
949 __asm mov cl, byte ptr shift\
951 __asm mov value, eax\
952 __asm setc byte ptr C_OUT
953 #define ARITHMETIC_LSL_REG \
954 __asm mov eax, opcode\
956 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
957 __asm mov cl, byte ptr shift\
961 #define ARITHMETIC_LSR_REG \
962 __asm mov eax, opcode\
964 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
965 __asm mov cl, byte ptr shift\
969 #define ARITHMETIC_ASR_REG \
970 __asm mov eax, opcode\
972 __asm mov eax, dword ptr [OFFSET reg + 4 * eax]\
973 __asm mov cl, byte ptr shift\
977 #define ARITHMETIC_ROR_REG \
978 __asm mov eax, opcode\
980 __asm mov eax, dword ptr [OFFSET reg + 4*eax]\
981 __asm mov cl, byte ptr shift\
985 #define ARITHMETIC_RRX_REG \
986 __asm mov eax, opcode\
988 __asm mov eax, dword ptr [OFFSET reg + 4*eax]\
989 __asm bt word ptr C_FLAG, 0\
993 #define ARITHMETIC_ROR_IMM \
994 __asm mov eax, opcode\
996 __asm mov cl, byte ptr shift\
999 #define ROR_IMM_MSR \
1001 __asm mov eax, opcode\
1002 __asm and eax, 0xff\
1003 __asm mov cl, byte ptr shift\
1005 __asm mov value, eax\
1009 __asm mov cl, byte ptr shift\
1010 __asm ror dword ptr value, cl\
1014 __asm mov cl, byte ptr shift\
1015 __asm bt word ptr C_FLAG, 0\
1016 __asm rcr dword ptr value, 1\
1022 u32 res = reg[base].I & value;\
1023 N_FLAG = (res & 0x80000000) ? true : false;\
1024 Z_FLAG = (res) ? false : true;\
1028 u32 res = reg[base].I ^ value;\
1029 N_FLAG = (res & 0x80000000) ? true : false;\
1030 Z_FLAG = (res) ? false : true;\
1034 reg[dest].I = reg[base].I | value;
1037 reg[dest].I = reg[base].I | value;\
1038 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
1039 Z_FLAG = (reg[dest].I) ? false : true;\
1043 reg[dest].I = value;
1046 reg[dest].I = value;\
1047 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
1048 Z_FLAG = (reg[dest].I) ? false : true;\
1052 reg[dest].I = reg[base].I & (~value);
1055 reg[dest].I = reg[base].I & (~value);\
1056 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
1057 Z_FLAG = (reg[dest].I) ? false : true;\
1061 reg[dest].I = ~value;
1064 reg[dest].I = ~value; \
1065 N_FLAG = (reg[dest].I & 0x80000000) ? true : false;\
1066 Z_FLAG = (reg[dest].I) ? false : true;\
1069 #define CASE_16(BASE) \
1087 #define CASE_256(BASE) \
1105 #define LOGICAL_DATA_OPCODE(OPCODE, OPCODE2, BASE) \
1109 /* OP Rd,Rb,Rm LSL # */ \
1110 int base = (opcode >> 16) & 0x0F;\
1111 int shift = (opcode >> 7) & 0x1F;\
1112 int dest = (opcode>>12) & 15;\
1113 bool C_OUT = C_FLAG;\
1116 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1118 clockTicks = 1+codeTicksAccess32(armNextPC);\
1119 if ((opcode & 0x02000010)==0x10)\
1125 value = reg[opcode & 0x0F].I;\
1128 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1131 if(opcode & 0x00100000) {\
1132 CPUSwitchMode(reg[17].I & 0x1f, false);\
1135 reg[15].I &= 0xFFFFFFFC;\
1136 armNextPC = reg[15].I;\
1140 reg[15].I &= 0xFFFFFFFE;\
1141 armNextPC = reg[15].I;\
1153 /* OP Rd,Rb,Rm LSR # */ \
1154 int base = (opcode >> 16) & 0x0F;\
1155 int shift = (opcode >> 7) & 0x1F;\
1156 int dest = (opcode>>12) & 15;\
1157 bool C_OUT = C_FLAG;\
1159 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1161 clockTicks = 1+codeTicksAccess32(armNextPC);\
1162 if ((opcode & 0x02000010)==0x10)\
1169 C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false;\
1173 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1176 if(opcode & 0x00100000) {\
1177 CPUSwitchMode(reg[17].I & 0x1f, false);\
1180 reg[15].I &= 0xFFFFFFFC;\
1181 armNextPC = reg[15].I;\
1185 reg[15].I &= 0xFFFFFFFE;\
1186 armNextPC = reg[15].I;\
1198 /* OP Rd,Rb,Rm ASR # */\
1199 int base = (opcode >> 16) & 0x0F;\
1200 int shift = (opcode >> 7) & 0x1F;\
1201 int dest = (opcode>>12) & 15;\
1202 bool C_OUT = C_FLAG;\
1204 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1206 clockTicks = 1+codeTicksAccess32(armNextPC);\
1207 if ((opcode & 0x02000010)==0x10)\
1213 if(reg[opcode & 0x0F].I & 0x80000000){\
1214 value = 0xFFFFFFFF;\
1223 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1226 if(opcode & 0x00100000) {\
1227 CPUSwitchMode(reg[17].I & 0x1f, false);\
1230 reg[15].I &= 0xFFFFFFFC;\
1231 armNextPC = reg[15].I;\
1235 reg[15].I &= 0xFFFFFFFE;\
1236 armNextPC = reg[15].I;\
1248 /* OP Rd,Rb,Rm ROR # */\
1249 int base = (opcode >> 16) & 0x0F;\
1250 int shift = (opcode >> 7) & 0x1F;\
1251 int dest = (opcode>>12) & 15;\
1252 bool C_OUT = C_FLAG;\
1254 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1256 clockTicks = 1+codeTicksAccess32(armNextPC);\
1257 if ((opcode & 0x02000010)==0x10)\
1266 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1269 if(opcode & 0x00100000) {\
1270 CPUSwitchMode(reg[17].I & 0x1f, false);\
1273 reg[15].I &= 0xFFFFFFFC;\
1274 armNextPC = reg[15].I;\
1278 reg[15].I &= 0xFFFFFFFE;\
1279 armNextPC = reg[15].I;\
1290 /* OP Rd,Rb,Rm LSL Rs */\
1291 int base = (opcode >> 16) & 0x0F;\
1292 int shift = reg[(opcode >> 8)&15].B.B0;\
1293 int dest = (opcode>>12) & 15;\
1294 bool C_OUT = C_FLAG;\
1296 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1298 clockTicks = 1+codeTicksAccess32(armNextPC);\
1299 if ((opcode & 0x02000010)==0x10)\
1305 C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false);\
1306 } else if(shift < 32) {\
1313 value = reg[opcode & 0x0F].I;\
1316 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1319 if(opcode & 0x00100000) {\
1320 CPUSwitchMode(reg[17].I & 0x1f, false);\
1323 reg[15].I &= 0xFFFFFFFC;\
1324 armNextPC = reg[15].I;\
1328 reg[15].I &= 0xFFFFFFFE;\
1329 armNextPC = reg[15].I;\
1340 /* OP Rd,Rb,Rm LSR Rs */ \
1341 int base = (opcode >> 16) & 0x0F;\
1342 int shift = reg[(opcode >> 8)&15].B.B0;\
1343 int dest = (opcode>>12) & 15;\
1344 bool C_OUT = C_FLAG;\
1346 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1348 clockTicks = 1+codeTicksAccess32(armNextPC);\
1349 if ((opcode & 0x02000010)==0x10)\
1355 C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false);\
1356 } else if(shift < 32) {\
1363 value = reg[opcode & 0x0F].I;\
1366 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1369 if(opcode & 0x00100000) {\
1370 CPUSwitchMode(reg[17].I & 0x1f, false);\
1373 reg[15].I &= 0xFFFFFFFC;\
1374 armNextPC = reg[15].I;\
1378 reg[15].I &= 0xFFFFFFFE;\
1379 armNextPC = reg[15].I;\
1390 /* OP Rd,Rb,Rm ASR Rs */ \
1391 int base = (opcode >> 16) & 0x0F;\
1392 int shift = reg[(opcode >> 8)&15].B.B0;\
1393 int dest = (opcode>>12) & 15;\
1394 bool C_OUT = C_FLAG;\
1396 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1398 clockTicks = 1+codeTicksAccess32(armNextPC);\
1399 if ((opcode & 0x02000010)==0x10)\
1406 value = reg[opcode & 0x0F].I;\
1409 if(reg[opcode & 0x0F].I & 0x80000000){\
1410 value = 0xFFFFFFFF;\
1418 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1421 if(opcode & 0x00100000) {\
1422 CPUSwitchMode(reg[17].I & 0x1f, false);\
1425 reg[15].I &= 0xFFFFFFFC;\
1426 armNextPC = reg[15].I;\
1430 reg[15].I &= 0xFFFFFFFE;\
1431 armNextPC = reg[15].I;\
1442 /* OP Rd,Rb,Rm ROR Rs */\
1443 int base = (opcode >> 16) & 0x0F;\
1444 int shift = reg[(opcode >> 8)&15].B.B0;\
1445 int dest = (opcode>>12) & 15;\
1446 bool C_OUT = C_FLAG;\
1448 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1450 clockTicks = 1+codeTicksAccess32(armNextPC);\
1451 if ((opcode & 0x02000010)==0x10)\
1459 value = reg[opcode & 0x0F].I;\
1460 C_OUT = (value & 0x80000000 ? true : false);\
1463 value = reg[opcode & 0x0F].I;\
1464 C_OUT = (value & 0x80000000 ? true : false);\
1467 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1470 if(opcode & 0x00100000) {\
1471 CPUSwitchMode(reg[17].I & 0x1f, false);\
1474 reg[15].I &= 0xFFFFFFFC;\
1475 armNextPC = reg[15].I;\
1479 reg[15].I &= 0xFFFFFFFE;\
1480 armNextPC = reg[15].I;\
1506 int shift = (opcode & 0xF00) >> 7;\
1507 int base = (opcode >> 16) & 0x0F;\
1508 int dest = (opcode >> 12) & 0x0F;\
1509 bool C_OUT = C_FLAG;\
1511 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1513 clockTicks = 1+codeTicksAccess32(armNextPC);\
1514 if ((opcode & 0x02000010)==0x10)\
1520 value = opcode & 0xff;\
1523 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1526 if(opcode & 0x00100000) {\
1527 CPUSwitchMode(reg[17].I & 0x1f, false);\
1530 reg[15].I &= 0xFFFFFFFC;\
1531 armNextPC = reg[15].I;\
1535 reg[15].I &= 0xFFFFFFFE;\
1536 armNextPC = reg[15].I;\
1546 #define LOGICAL_DATA_OPCODE_WITHOUT_base(OPCODE, OPCODE2, BASE) \
1550 /* OP Rd,Rb,Rm LSL # */ \
1551 int shift = (opcode >> 7) & 0x1F;\
1552 int dest = (opcode>>12) & 15;\
1553 bool C_OUT = C_FLAG;\
1555 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1557 clockTicks = 1+codeTicksAccess32(armNextPC);\
1558 if ((opcode & 0x02000010)==0x10)\
1565 value = reg[opcode & 0x0F].I;\
1568 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1571 if(opcode & 0x00100000) {\
1572 CPUSwitchMode(reg[17].I & 0x1f, false);\
1575 reg[15].I &= 0xFFFFFFFC;\
1576 armNextPC = reg[15].I;\
1580 reg[15].I &= 0xFFFFFFFE;\
1581 armNextPC = reg[15].I;\
1593 /* OP Rd,Rb,Rm LSR # */ \
1594 int shift = (opcode >> 7) & 0x1F;\
1595 int dest = (opcode>>12) & 15;\
1596 bool C_OUT = C_FLAG;\
1598 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1600 clockTicks = 1+codeTicksAccess32(armNextPC);\
1601 if ((opcode & 0x02000010)==0x10)\
1608 C_OUT = (reg[opcode & 0x0F].I & 0x80000000) ? true : false;\
1612 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1615 if(opcode & 0x00100000) {\
1616 CPUSwitchMode(reg[17].I & 0x1f, false);\
1619 reg[15].I &= 0xFFFFFFFC;\
1620 armNextPC = reg[15].I;\
1624 reg[15].I &= 0xFFFFFFFE;\
1625 armNextPC = reg[15].I;\
1637 /* OP Rd,Rb,Rm ASR # */\
1638 int shift = (opcode >> 7) & 0x1F;\
1639 int dest = (opcode>>12) & 15;\
1640 bool C_OUT = C_FLAG;\
1642 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1644 clockTicks = 1+codeTicksAccess32(armNextPC);\
1645 if ((opcode & 0x02000010)==0x10)\
1651 if(reg[opcode & 0x0F].I & 0x80000000){\
1652 value = 0xFFFFFFFF;\
1661 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1664 if(opcode & 0x00100000) {\
1665 CPUSwitchMode(reg[17].I & 0x1f, false);\
1668 reg[15].I &= 0xFFFFFFFC;\
1669 armNextPC = reg[15].I;\
1673 reg[15].I &= 0xFFFFFFFE;\
1674 armNextPC = reg[15].I;\
1686 /* OP Rd,Rb,Rm ROR # */\
1687 int shift = (opcode >> 7) & 0x1F;\
1688 int dest = (opcode>>12) & 15;\
1689 bool C_OUT = C_FLAG;\
1691 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1693 clockTicks = 1+codeTicksAccess32(armNextPC);\
1694 if ((opcode & 0x02000010)==0x10)\
1703 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1706 if(opcode & 0x00100000) {\
1707 CPUSwitchMode(reg[17].I & 0x1f, false);\
1710 reg[15].I &= 0xFFFFFFFC;\
1711 armNextPC = reg[15].I;\
1715 reg[15].I &= 0xFFFFFFFE;\
1716 armNextPC = reg[15].I;\
1727 /* OP Rd,Rb,Rm LSL Rs */\
1728 int shift = reg[(opcode >> 8)&15].B.B0;\
1729 int dest = (opcode>>12) & 15;\
1730 bool C_OUT = C_FLAG;\
1732 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1734 clockTicks = 1+codeTicksAccess32(armNextPC);\
1735 if ((opcode & 0x02000010)==0x10)\
1741 C_OUT = (reg[opcode & 0x0F].I & 1 ? true : false);\
1742 } else if(shift < 32) {\
1749 value = reg[opcode & 0x0F].I;\
1752 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1755 if(opcode & 0x00100000) {\
1756 CPUSwitchMode(reg[17].I & 0x1f, false);\
1759 reg[15].I &= 0xFFFFFFFC;\
1760 armNextPC = reg[15].I;\
1764 reg[15].I &= 0xFFFFFFFE;\
1765 armNextPC = reg[15].I;\
1776 /* OP Rd,Rb,Rm LSR Rs */ \
1777 int shift = reg[(opcode >> 8)&15].B.B0;\
1778 int dest = (opcode>>12) & 15;\
1779 bool C_OUT = C_FLAG;\
1781 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1783 clockTicks = 1+codeTicksAccess32(armNextPC);\
1784 if ((opcode & 0x02000010)==0x10)\
1790 C_OUT = (reg[opcode & 0x0F].I & 0x80000000 ? true : false);\
1791 } else if(shift < 32) {\
1798 value = reg[opcode & 0x0F].I;\
1801 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1804 if(opcode & 0x00100000) {\
1805 CPUSwitchMode(reg[17].I & 0x1f, false);\
1808 reg[15].I &= 0xFFFFFFFC;\
1809 armNextPC = reg[15].I;\
1813 reg[15].I &= 0xFFFFFFFE;\
1814 armNextPC = reg[15].I;\
1825 /* OP Rd,Rb,Rm ASR Rs */ \
1826 int shift = reg[(opcode >> 8)&15].B.B0;\
1827 int dest = (opcode>>12) & 15;\
1828 bool C_OUT = C_FLAG;\
1830 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1832 clockTicks = 1+codeTicksAccess32(armNextPC);\
1833 if ((opcode & 0x02000010)==0x10)\
1840 value = reg[opcode & 0x0F].I;\
1843 if(reg[opcode & 0x0F].I & 0x80000000){\
1844 value = 0xFFFFFFFF;\
1852 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1855 if(opcode & 0x00100000) {\
1856 CPUSwitchMode(reg[17].I & 0x1f, false);\
1859 reg[15].I &= 0xFFFFFFFC;\
1860 armNextPC = reg[15].I;\
1864 reg[15].I &= 0xFFFFFFFE;\
1865 armNextPC = reg[15].I;\
1876 /* OP Rd,Rb,Rm ROR Rs */\
1877 int shift = reg[(opcode >> 8)&15].B.B0;\
1878 int dest = (opcode>>12) & 15;\
1879 bool C_OUT = C_FLAG;\
1881 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1883 clockTicks = 1+codeTicksAccess32(armNextPC);\
1884 if ((opcode & 0x02000010)==0x10)\
1892 value = reg[opcode & 0x0F].I;\
1893 C_OUT = (value & 0x80000000 ? true : false);\
1896 value = reg[opcode & 0x0F].I;\
1897 C_OUT = (value & 0x80000000 ? true : false);\
1900 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1903 if(opcode & 0x00100000) {\
1904 CPUSwitchMode(reg[17].I & 0x1f, false);\
1907 reg[15].I &= 0xFFFFFFFC;\
1908 armNextPC = reg[15].I;\
1912 reg[15].I &= 0xFFFFFFFE;\
1913 armNextPC = reg[15].I;\
1939 int shift = (opcode & 0xF00) >> 7;\
1940 int dest = (opcode >> 12) & 0x0F;\
1941 bool C_OUT = C_FLAG;\
1943 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1945 clockTicks = 1+codeTicksAccess32(armNextPC);\
1946 if ((opcode & 0x02000010)==0x10)\
1952 value = opcode & 0xff;\
1955 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
1958 if(opcode & 0x00100000) {\
1959 CPUSwitchMode(reg[17].I & 0x1f, false);\
1962 reg[15].I &= 0xFFFFFFFC;\
1963 armNextPC = reg[15].I;\
1967 reg[15].I &= 0xFFFFFFFE;\
1968 armNextPC = reg[15].I;\
1978 #define ARITHMETIC_DATA_OPCODE(OPCODE, OPCODE2, BASE) \
1982 /* OP Rd,Rb,Rm LSL # */\
1983 int base = (opcode >> 16) & 0x0F;\
1984 int shift = (opcode >> 7) & 0x1F;\
1985 int dest = (opcode>>12) & 15;\
1987 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
1989 clockTicks = 1+codeTicksAccess32(armNextPC);\
1990 if ((opcode & 0x02000010)==0x10)\
1996 value = reg[opcode & 0x0F].I;\
1999 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2002 if(opcode & 0x00100000) {\
2003 CPUSwitchMode(reg[17].I & 0x1f, false);\
2006 reg[15].I &= 0xFFFFFFFC;\
2007 armNextPC = reg[15].I;\
2011 reg[15].I &= 0xFFFFFFFE;\
2012 armNextPC = reg[15].I;\
2024 /* OP Rd,Rb,Rm LSR # */\
2025 int base = (opcode >> 16) & 0x0F;\
2026 int shift = (opcode >> 7) & 0x1F;\
2027 int dest = (opcode>>12) & 15;\
2029 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2031 clockTicks = 1+codeTicksAccess32(armNextPC);\
2032 if ((opcode & 0x02000010)==0x10)\
2041 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2044 if(opcode & 0x00100000) {\
2045 CPUSwitchMode(reg[17].I & 0x1f, false);\
2048 reg[15].I &= 0xFFFFFFFC;\
2049 armNextPC = reg[15].I;\
2053 reg[15].I &= 0xFFFFFFFE;\
2054 armNextPC = reg[15].I;\
2066 /* OP Rd,Rb,Rm ASR # */\
2067 int base = (opcode >> 16) & 0x0F;\
2068 int shift = (opcode >> 7) & 0x1F;\
2069 int dest = (opcode>>12) & 15;\
2071 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2073 clockTicks = 1+codeTicksAccess32(armNextPC);\
2074 if ((opcode & 0x02000010)==0x10)\
2080 if(reg[opcode & 0x0F].I & 0x80000000){\
2081 value = 0xFFFFFFFF;\
2085 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2088 if(opcode & 0x00100000) {\
2089 CPUSwitchMode(reg[17].I & 0x1f, false);\
2092 reg[15].I &= 0xFFFFFFFC;\
2093 armNextPC = reg[15].I;\
2097 reg[15].I &= 0xFFFFFFFE;\
2098 armNextPC = reg[15].I;\
2110 /* OP Rd,Rb,Rm ROR # */\
2111 int base = (opcode >> 16) & 0x0F;\
2112 int shift = (opcode >> 7) & 0x1F;\
2113 int dest = (opcode>>12) & 15;\
2115 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2117 clockTicks = 1+codeTicksAccess32(armNextPC);\
2118 if ((opcode & 0x02000010)==0x10)\
2127 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2130 if(opcode & 0x00100000) {\
2131 CPUSwitchMode(reg[17].I & 0x1f, false);\
2134 reg[15].I &= 0xFFFFFFFC;\
2135 armNextPC = reg[15].I;\
2139 reg[15].I &= 0xFFFFFFFE;\
2140 armNextPC = reg[15].I;\
2151 /* OP Rd,Rb,Rm LSL Rs */\
2152 int base = (opcode >> 16) & 0x0F;\
2153 int shift = reg[(opcode >> 8)&15].B.B0;\
2154 int dest = (opcode>>12) & 15;\
2156 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2158 clockTicks = 1+codeTicksAccess32(armNextPC);\
2159 if ((opcode & 0x02000010)==0x10)\
2165 } else if(shift < 32) {\
2169 value = reg[opcode & 0x0F].I;\
2172 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2175 if(opcode & 0x00100000) {\
2176 CPUSwitchMode(reg[17].I & 0x1f, false);\
2179 reg[15].I &= 0xFFFFFFFC;\
2180 armNextPC = reg[15].I;\
2184 reg[15].I &= 0xFFFFFFFE;\
2185 armNextPC = reg[15].I;\
2196 /* OP Rd,Rb,Rm LSR Rs */\
2197 int base = (opcode >> 16) & 0x0F;\
2198 int shift = reg[(opcode >> 8)&15].B.B0;\
2199 int dest = (opcode>>12) & 15;\
2201 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2203 clockTicks = 1+codeTicksAccess32(armNextPC);\
2204 if ((opcode & 0x02000010)==0x10)\
2210 } else if(shift < 32) {\
2214 value = reg[opcode & 0x0F].I;\
2217 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2220 if(opcode & 0x00100000) {\
2221 CPUSwitchMode(reg[17].I & 0x1f, false);\
2224 reg[15].I &= 0xFFFFFFFC;\
2225 armNextPC = reg[15].I;\
2229 reg[15].I &= 0xFFFFFFFE;\
2230 armNextPC = reg[15].I;\
2241 /* OP Rd,Rb,Rm ASR Rs */\
2242 int base = (opcode >> 16) & 0x0F;\
2243 int shift = reg[(opcode >> 8)&15].B.B0;\
2244 int dest = (opcode>>12) & 15;\
2246 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2248 clockTicks = 1+codeTicksAccess32(armNextPC);\
2249 if ((opcode & 0x02000010)==0x10)\
2256 value = reg[opcode & 0x0F].I;\
2259 if(reg[opcode & 0x0F].I & 0x80000000){\
2260 value = 0xFFFFFFFF;\
2264 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2267 if(opcode & 0x00100000) {\
2268 CPUSwitchMode(reg[17].I & 0x1f, false);\
2271 reg[15].I &= 0xFFFFFFFC;\
2272 armNextPC = reg[15].I;\
2276 reg[15].I &= 0xFFFFFFFE;\
2277 armNextPC = reg[15].I;\
2288 /* OP Rd,Rb,Rm ROR Rs */\
2289 int base = (opcode >> 16) & 0x0F;\
2290 int shift = reg[(opcode >> 8)&15].B.B0;\
2291 int dest = (opcode>>12) & 15;\
2293 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2295 clockTicks = 1+codeTicksAccess32(armNextPC);\
2296 if ((opcode & 0x02000010)==0x10)\
2304 value = reg[opcode & 0x0F].I;\
2307 value = reg[opcode & 0x0F].I;\
2310 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2313 if(opcode & 0x00100000) {\
2314 CPUSwitchMode(reg[17].I & 0x1f, false);\
2317 reg[15].I &= 0xFFFFFFFC;\
2318 armNextPC = reg[15].I;\
2322 reg[15].I &= 0xFFFFFFFE;\
2323 armNextPC = reg[15].I;\
2349 int shift = (opcode & 0xF00) >> 7;\
2350 int base = (opcode >> 16) & 0x0F;\
2351 int dest = (opcode >> 12) & 0x0F;\
2353 if ((dest == 15)||((opcode & 0x02000010)==0x10))\
2355 clockTicks = 1+codeTicksAccess32(armNextPC);\
2356 if ((opcode & 0x02000010)==0x10)\
2363 clockTicks+=2+codeTicksAccessSeq32(armNextPC)+codeTicksAccessSeq32(armNextPC);\
2366 if(opcode & 0x00100000) {\
2367 CPUSwitchMode(reg[17].I & 0x1f, false);\
2370 reg[15].I &= 0xFFFFFFFC;\
2371 armNextPC = reg[15].I;\
2375 reg[15].I &= 0xFFFFFFFE;\
2376 armNextPC = reg[15].I;\
2386 u32 opcode
= cpuPrefetch
[0];
2387 cpuPrefetch
[0] = cpuPrefetch
[1];
2389 busPrefetch
= false;
2390 if (busPrefetchCount
& 0xFFFFFE00)
2391 busPrefetchCount
= 0x100 | (busPrefetchCount
& 0xFF);
2394 clockTicks
= 0;//codeTicksAccessSeq32(armNextPC)+1;
2395 int oldArmNextPC
= armNextPC
;
2397 #ifndef FINAL_VERSION
2398 if(armNextPC
== stop
) {
2403 armNextPC
= reg
[15].I
;
2407 int cond
= opcode
>> 28;
2408 // suggested optimization for frequent cases
2439 cond_res
= C_FLAG
&& !Z_FLAG
;
2442 cond_res
= !C_FLAG
|| Z_FLAG
;
2445 cond_res
= N_FLAG
== V_FLAG
;
2448 cond_res
= N_FLAG
!= V_FLAG
;
2451 cond_res
= !Z_FLAG
&&(N_FLAG
== V_FLAG
);
2454 cond_res
= Z_FLAG
|| (N_FLAG
!= V_FLAG
);
2468 switch(((opcode
>>16)&0xFF0) | ((opcode
>>4)&0x0F)) {
2469 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_AND
, OP_AND
, 0x000);
2470 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_ANDS
, OP_AND
, 0x010);
2474 int dest
= (opcode
>> 16) & 0x0F;
2475 int mult
= (opcode
& 0x0F);
2477 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
2478 reg
[dest
].I
= reg
[mult
].I
* rs
;
2481 if((rs
& 0xFFFFFF00) == 0)
2483 else if ((rs
& 0xFFFF0000) == 0)
2485 else if ((rs
& 0xFF000000) == 0)
2489 if (!busPrefetchCount
)
2490 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
2491 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
2498 int dest
= (opcode
>> 16) & 0x0F;
2499 int mult
= (opcode
& 0x0F);
2501 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
2502 reg
[dest
].I
= reg
[mult
].I
* rs
;
2503 N_FLAG
= (reg
[dest
].I
& 0x80000000) ? true : false;
2504 Z_FLAG
= (reg
[dest
].I
) ? false : true;
2507 if((rs
& 0xFFFFFF00) == 0)
2509 else if ((rs
& 0xFFFF0000) == 0)
2511 else if ((rs
& 0xFF000000) == 0)
2515 if (!busPrefetchCount
)
2516 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
2517 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
2523 // STRH Rd, [Rn], -Rm
2524 if (!busPrefetchCount
)
2525 busPrefetch
= busPrefetchEnable
;
2526 int base
= (opcode
>> 16) & 0x0F;
2527 int dest
= (opcode
>> 12) & 0x0F;
2528 u32 address
= reg
[base
].I
;
2529 int offset
= reg
[opcode
& 0x0F].I
;
2530 clockTicks
= 2 + dataTicksAccess16(address
) +
2531 codeTicksAccess32(armNextPC
);
2532 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2534 reg
[base
].I
= address
;
2540 // STRH Rd, [Rn], #-offset
2541 if (!busPrefetchCount
)
2542 busPrefetch
= busPrefetchEnable
;
2543 int base
= (opcode
>> 16) & 0x0F;
2544 int dest
= (opcode
>> 12) & 0x0F;
2545 u32 address
= reg
[base
].I
;
2546 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
2547 clockTicks
= 2 + dataTicksAccess16(address
)
2548 + codeTicksAccess32(armNextPC
);
2549 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2551 reg
[base
].I
= address
;
2557 // STRH Rd, [Rn], Rm
2558 if (!busPrefetchCount
)
2559 busPrefetch
= busPrefetchEnable
;
2560 int base
= (opcode
>> 16) & 0x0F;
2561 int dest
= (opcode
>> 12) & 0x0F;
2562 u32 address
= reg
[base
].I
;
2563 int offset
= reg
[opcode
& 0x0F].I
;
2564 clockTicks
= 2 + dataTicksAccess16(address
) +
2565 codeTicksAccess32(armNextPC
);
2566 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2568 reg
[base
].I
= address
;
2574 // STRH Rd, [Rn], #offset
2575 if (!busPrefetchCount
)
2576 busPrefetch
= busPrefetchEnable
;
2577 int base
= (opcode
>> 16) & 0x0F;
2578 int dest
= (opcode
>> 12) & 0x0F;
2579 u32 address
= reg
[base
].I
;
2580 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
2581 clockTicks
= 2 + dataTicksAccess16(address
) +
2582 codeTicksAccess32(armNextPC
);
2583 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2585 reg
[base
].I
= address
;
2590 // STRH Rd, [Rn, -Rm]
2591 if (!busPrefetchCount
)
2592 busPrefetch
= busPrefetchEnable
;
2593 int base
= (opcode
>> 16) & 0x0F;
2594 int dest
= (opcode
>> 12) & 0x0F;
2595 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
2596 clockTicks
= 2 + dataTicksAccess16(address
) +
2597 codeTicksAccess32(armNextPC
);
2598 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2603 // STRH Rd, [Rn, -Rm]!
2604 if (!busPrefetchCount
)
2605 busPrefetch
= busPrefetchEnable
;
2606 int base
= (opcode
>> 16) & 0x0F;
2607 int dest
= (opcode
>> 12) & 0x0F;
2608 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
2609 clockTicks
= 2 + dataTicksAccess16(address
) +
2610 codeTicksAccess32(armNextPC
);
2611 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2612 reg
[base
].I
= address
;
2617 // STRH Rd, [Rn, -#offset]
2618 if (!busPrefetchCount
)
2619 busPrefetch
= busPrefetchEnable
;
2620 int base
= (opcode
>> 16) & 0x0F;
2621 int dest
= (opcode
>> 12) & 0x0F;
2622 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2623 clockTicks
= 2 + dataTicksAccess16(address
) +
2624 codeTicksAccess32(armNextPC
);
2625 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2630 // STRH Rd, [Rn, -#offset]!
2631 if (!busPrefetchCount
)
2632 busPrefetch
= busPrefetchEnable
;
2633 int base
= (opcode
>> 16) & 0x0F;
2634 int dest
= (opcode
>> 12) & 0x0F;
2635 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2636 clockTicks
= 2 + dataTicksAccess16(address
) +
2637 codeTicksAccess32(armNextPC
);
2638 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2639 reg
[base
].I
= address
;
2644 // STRH Rd, [Rn, Rm]
2645 if (!busPrefetchCount
)
2646 busPrefetch
= busPrefetchEnable
;
2647 int base
= (opcode
>> 16) & 0x0F;
2648 int dest
= (opcode
>> 12) & 0x0F;
2649 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
2650 clockTicks
= 2 + dataTicksAccess16(address
) +
2651 codeTicksAccess32(armNextPC
);
2652 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2657 // STRH Rd, [Rn, Rm]!
2658 if (!busPrefetchCount
)
2659 busPrefetch
= busPrefetchEnable
;
2660 int base
= (opcode
>> 16) & 0x0F;
2661 int dest
= (opcode
>> 12) & 0x0F;
2662 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
2663 clockTicks
= 2 + dataTicksAccess16(address
) +
2664 codeTicksAccess32(armNextPC
);
2665 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2666 reg
[base
].I
= address
;
2671 // STRH Rd, [Rn, #offset]
2672 if (!busPrefetchCount
)
2673 busPrefetch
= busPrefetchEnable
;
2674 int base
= (opcode
>> 16) & 0x0F;
2675 int dest
= (opcode
>> 12) & 0x0F;
2676 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2677 clockTicks
= 2 + dataTicksAccess16(address
) +
2678 codeTicksAccess32(armNextPC
);
2679 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2684 // STRH Rd, [Rn, #offset]!
2685 if (!busPrefetchCount
)
2686 busPrefetch
= busPrefetchEnable
;
2687 int base
= (opcode
>> 16) & 0x0F;
2688 int dest
= (opcode
>> 12) & 0x0F;
2689 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2690 clockTicks
= 2 + dataTicksAccess16(address
) +
2691 codeTicksAccess32(armNextPC
);
2692 CPUWriteHalfWord(address
, reg
[dest
].W
.W0
);
2693 reg
[base
].I
= address
;
2699 // LDRH Rd, [Rn], -Rm
2700 if (!busPrefetchCount
)
2701 busPrefetch
= busPrefetchEnable
;
2702 int base
= (opcode
>> 16) & 0x0F;
2703 int dest
= (opcode
>> 12) & 0x0F;
2704 u32 address
= reg
[base
].I
;
2705 int offset
= reg
[opcode
& 0x0F].I
;
2706 reg
[dest
].I
= CPUReadHalfWord(address
);
2709 reg
[base
].I
= address
;
2713 reg
[15].I
&= 0xFFFFFFFC;
2714 armNextPC
= reg
[15].I
;
2717 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2719 clockTicks
+= 3 + dataTicksAccess16(address
) +
2720 codeTicksAccess32(armNextPC
);
2726 // LDRH Rd, [Rn], #-offset
2727 if (!busPrefetchCount
)
2728 busPrefetch
= busPrefetchEnable
;
2729 int base
= (opcode
>> 16) & 0x0F;
2730 int dest
= (opcode
>> 12) & 0x0F;
2731 u32 address
= reg
[base
].I
;
2732 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
2733 reg
[dest
].I
= CPUReadHalfWord(address
);
2736 reg
[base
].I
= address
;
2740 reg
[15].I
&= 0xFFFFFFFC;
2741 armNextPC
= reg
[15].I
;
2744 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2746 clockTicks
+= 3 + dataTicksAccess16(address
) +
2747 codeTicksAccess32(armNextPC
);
2753 // LDRH Rd, [Rn], Rm
2754 if (!busPrefetchCount
)
2755 busPrefetch
= busPrefetchEnable
;
2756 int base
= (opcode
>> 16) & 0x0F;
2757 int dest
= (opcode
>> 12) & 0x0F;
2758 u32 address
= reg
[base
].I
;
2759 int offset
= reg
[opcode
& 0x0F].I
;
2760 reg
[dest
].I
= CPUReadHalfWord(address
);
2763 reg
[base
].I
= address
;
2767 reg
[15].I
&= 0xFFFFFFFC;
2768 armNextPC
= reg
[15].I
;
2771 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2773 clockTicks
+= 3 + dataTicksAccess16(address
) +
2774 codeTicksAccess32(armNextPC
);
2780 // LDRH Rd, [Rn], #offset
2781 if (!busPrefetchCount
)
2782 busPrefetch
= busPrefetchEnable
;
2783 int base
= (opcode
>> 16) & 0x0F;
2784 int dest
= (opcode
>> 12) & 0x0F;
2785 u32 address
= reg
[base
].I
;
2786 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
2787 reg
[dest
].I
= CPUReadHalfWord(address
);
2790 reg
[base
].I
= address
;
2794 reg
[15].I
&= 0xFFFFFFFC;
2795 armNextPC
= reg
[15].I
;
2798 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2800 clockTicks
+= 3 + dataTicksAccess16(address
) +
2801 codeTicksAccess32(armNextPC
);
2806 // LDRH Rd, [Rn, -Rm]
2807 if (!busPrefetchCount
)
2808 busPrefetch
= busPrefetchEnable
;
2809 int base
= (opcode
>> 16) & 0x0F;
2810 int dest
= (opcode
>> 12) & 0x0F;
2811 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
2812 reg
[dest
].I
= CPUReadHalfWord(address
);
2815 reg
[15].I
&= 0xFFFFFFFC;
2816 armNextPC
= reg
[15].I
;
2819 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2821 clockTicks
+= 3 + dataTicksAccess16(address
) +
2822 codeTicksAccess32(armNextPC
);
2827 // LDRH Rd, [Rn, -Rm]!
2828 if (!busPrefetchCount
)
2829 busPrefetch
= busPrefetchEnable
;
2830 int base
= (opcode
>> 16) & 0x0F;
2831 int dest
= (opcode
>> 12) & 0x0F;
2832 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
2833 reg
[dest
].I
= CPUReadHalfWord(address
);
2835 reg
[base
].I
= address
;
2838 reg
[15].I
&= 0xFFFFFFFC;
2839 armNextPC
= reg
[15].I
;
2842 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2844 clockTicks
+= 3 + dataTicksAccess16(address
) +
2845 codeTicksAccess32(armNextPC
);
2850 // LDRH Rd, [Rn, -#offset]
2851 if (!busPrefetchCount
)
2852 busPrefetch
= busPrefetchEnable
;
2853 int base
= (opcode
>> 16) & 0x0F;
2854 int dest
= (opcode
>> 12) & 0x0F;
2855 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2856 reg
[dest
].I
= CPUReadHalfWord(address
);
2859 reg
[15].I
&= 0xFFFFFFFC;
2860 armNextPC
= reg
[15].I
;
2863 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2865 clockTicks
+= 3 + dataTicksAccess16(address
) +
2866 codeTicksAccess32(armNextPC
);
2871 // LDRH Rd, [Rn, -#offset]!
2872 if (!busPrefetchCount
)
2873 busPrefetch
= busPrefetchEnable
;
2874 int base
= (opcode
>> 16) & 0x0F;
2875 int dest
= (opcode
>> 12) & 0x0F;
2876 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2877 reg
[dest
].I
= CPUReadHalfWord(address
);
2879 reg
[base
].I
= address
;
2882 reg
[15].I
&= 0xFFFFFFFC;
2883 armNextPC
= reg
[15].I
;
2886 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2888 clockTicks
+= 3 + dataTicksAccess16(address
) +
2889 codeTicksAccess32(armNextPC
);
2894 // LDRH Rd, [Rn, Rm]
2895 if (!busPrefetchCount
)
2896 busPrefetch
= busPrefetchEnable
;
2897 int base
= (opcode
>> 16) & 0x0F;
2898 int dest
= (opcode
>> 12) & 0x0F;
2899 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
2900 reg
[dest
].I
= CPUReadHalfWord(address
);
2903 reg
[15].I
&= 0xFFFFFFFC;
2904 armNextPC
= reg
[15].I
;
2907 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2909 clockTicks
+= 3 + dataTicksAccess16(address
) +
2910 codeTicksAccess32(armNextPC
);
2915 // LDRH Rd, [Rn, Rm]!
2916 if (!busPrefetchCount
)
2917 busPrefetch
= busPrefetchEnable
;
2918 int base
= (opcode
>> 16) & 0x0F;
2919 int dest
= (opcode
>> 12) & 0x0F;
2920 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
2921 reg
[dest
].I
= CPUReadHalfWord(address
);
2923 reg
[base
].I
= address
;
2926 reg
[15].I
&= 0xFFFFFFFC;
2927 armNextPC
= reg
[15].I
;
2930 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2932 clockTicks
+= 3 + dataTicksAccess16(address
) +
2933 codeTicksAccess32(armNextPC
);
2938 // LDRH Rd, [Rn, #offset]
2939 if (!busPrefetchCount
)
2940 busPrefetch
= busPrefetchEnable
;
2941 int base
= (opcode
>> 16) & 0x0F;
2942 int dest
= (opcode
>> 12) & 0x0F;
2943 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2944 reg
[dest
].I
= CPUReadHalfWord(address
);
2947 reg
[15].I
&= 0xFFFFFFFC;
2948 armNextPC
= reg
[15].I
;
2951 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2953 clockTicks
+= 3 + dataTicksAccess16(address
) +
2954 codeTicksAccess32(armNextPC
);
2959 // LDRH Rd, [Rn, #offset]!
2960 if (!busPrefetchCount
)
2961 busPrefetch
= busPrefetchEnable
;
2962 int base
= (opcode
>> 16) & 0x0F;
2963 int dest
= (opcode
>> 12) & 0x0F;
2964 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
2965 reg
[dest
].I
= CPUReadHalfWord(address
);
2967 reg
[base
].I
= address
;
2970 reg
[15].I
&= 0xFFFFFFFC;
2971 armNextPC
= reg
[15].I
;
2974 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
2976 clockTicks
+= 3 + dataTicksAccess16(address
) +
2977 codeTicksAccess32(armNextPC
);
2983 // LDRSB Rd, [Rn], -Rm
2984 if (!busPrefetchCount
)
2985 busPrefetch
= busPrefetchEnable
;
2986 int base
= (opcode
>> 16) & 0x0F;
2987 int dest
= (opcode
>> 12) & 0x0F;
2988 u32 address
= reg
[base
].I
;
2989 int offset
= reg
[opcode
& 0x0F].I
;
2990 reg
[dest
].I
= (s8
)CPUReadByte(address
);
2993 reg
[base
].I
= address
;
2997 reg
[15].I
&= 0xFFFFFFFC;
2998 armNextPC
= reg
[15].I
;
3001 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3003 clockTicks
+= 3 + dataTicksAccess16(address
) +
3004 codeTicksAccess32(armNextPC
);
3010 // LDRSB Rd, [Rn], #-offset
3011 if (!busPrefetchCount
)
3012 busPrefetch
= busPrefetchEnable
;
3013 int base
= (opcode
>> 16) & 0x0F;
3014 int dest
= (opcode
>> 12) & 0x0F;
3015 u32 address
= reg
[base
].I
;
3016 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
3017 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3020 reg
[base
].I
= address
;
3024 reg
[15].I
&= 0xFFFFFFFC;
3025 armNextPC
= reg
[15].I
;
3028 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3030 clockTicks
+= 3 + dataTicksAccess16(address
) +
3031 codeTicksAccess32(armNextPC
);
3037 // LDRSB Rd, [Rn], Rm
3038 if (!busPrefetchCount
)
3039 busPrefetch
= busPrefetchEnable
;
3040 int base
= (opcode
>> 16) & 0x0F;
3041 int dest
= (opcode
>> 12) & 0x0F;
3042 u32 address
= reg
[base
].I
;
3043 int offset
= reg
[opcode
& 0x0F].I
;
3044 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3047 reg
[base
].I
= address
;
3051 reg
[15].I
&= 0xFFFFFFFC;
3052 armNextPC
= reg
[15].I
;
3055 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3057 clockTicks
+= 3 + dataTicksAccess16(address
) +
3058 codeTicksAccess32(armNextPC
);
3064 // LDRSB Rd, [Rn], #offset
3065 if (!busPrefetchCount
)
3066 busPrefetch
= busPrefetchEnable
;
3067 int base
= (opcode
>> 16) & 0x0F;
3068 int dest
= (opcode
>> 12) & 0x0F;
3069 u32 address
= reg
[base
].I
;
3070 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
3071 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3074 reg
[base
].I
= address
;
3078 reg
[15].I
&= 0xFFFFFFFC;
3079 armNextPC
= reg
[15].I
;
3082 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3084 clockTicks
+= 3 + dataTicksAccess16(address
) +
3085 codeTicksAccess32(armNextPC
);
3090 // LDRSB Rd, [Rn, -Rm]
3091 if (!busPrefetchCount
)
3092 busPrefetch
= busPrefetchEnable
;
3093 int base
= (opcode
>> 16) & 0x0F;
3094 int dest
= (opcode
>> 12) & 0x0F;
3095 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
3096 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3099 reg
[15].I
&= 0xFFFFFFFC;
3100 armNextPC
= reg
[15].I
;
3103 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3105 clockTicks
+= 3 + dataTicksAccess16(address
) +
3106 codeTicksAccess32(armNextPC
);
3111 // LDRSB Rd, [Rn, -Rm]!
3112 if (!busPrefetchCount
)
3113 busPrefetch
= busPrefetchEnable
;
3114 int base
= (opcode
>> 16) & 0x0F;
3115 int dest
= (opcode
>> 12) & 0x0F;
3116 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
3117 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3119 reg
[base
].I
= address
;
3122 reg
[15].I
&= 0xFFFFFFFC;
3123 armNextPC
= reg
[15].I
;
3126 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3128 clockTicks
+= 3 + dataTicksAccess16(address
) +
3129 codeTicksAccess32(armNextPC
);
3134 // LDRSB Rd, [Rn, -#offset]
3135 if (!busPrefetchCount
)
3136 busPrefetch
= busPrefetchEnable
;
3137 int base
= (opcode
>> 16) & 0x0F;
3138 int dest
= (opcode
>> 12) & 0x0F;
3139 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3140 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3143 reg
[15].I
&= 0xFFFFFFFC;
3144 armNextPC
= reg
[15].I
;
3147 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3149 clockTicks
+= 3 + dataTicksAccess16(address
) +
3150 codeTicksAccess32(armNextPC
);
3155 // LDRSB Rd, [Rn, -#offset]!
3156 if (!busPrefetchCount
)
3157 busPrefetch
= busPrefetchEnable
;
3158 int base
= (opcode
>> 16) & 0x0F;
3159 int dest
= (opcode
>> 12) & 0x0F;
3160 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3161 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3163 reg
[base
].I
= address
;
3166 reg
[15].I
&= 0xFFFFFFFC;
3167 armNextPC
= reg
[15].I
;
3170 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3172 clockTicks
+= 3 + dataTicksAccess16(address
) +
3173 codeTicksAccess32(armNextPC
);
3178 // LDRSB Rd, [Rn, Rm]
3179 if (!busPrefetchCount
)
3180 busPrefetch
= busPrefetchEnable
;
3181 int base
= (opcode
>> 16) & 0x0F;
3182 int dest
= (opcode
>> 12) & 0x0F;
3183 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
3184 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3187 reg
[15].I
&= 0xFFFFFFFC;
3188 armNextPC
= reg
[15].I
;
3191 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3193 clockTicks
+= 3 + dataTicksAccess16(address
) +
3194 codeTicksAccess32(armNextPC
);
3199 // LDRSB Rd, [Rn, Rm]!
3200 if (!busPrefetchCount
)
3201 busPrefetch
= busPrefetchEnable
;
3202 int base
= (opcode
>> 16) & 0x0F;
3203 int dest
= (opcode
>> 12) & 0x0F;
3204 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
3205 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3207 reg
[base
].I
= address
;
3210 reg
[15].I
&= 0xFFFFFFFC;
3211 armNextPC
= reg
[15].I
;
3214 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3216 clockTicks
+= 3 + dataTicksAccess16(address
) +
3217 codeTicksAccess32(armNextPC
);
3222 // LDRSB Rd, [Rn, #offset]
3223 if (!busPrefetchCount
)
3224 busPrefetch
= busPrefetchEnable
;
3225 int base
= (opcode
>> 16) & 0x0F;
3226 int dest
= (opcode
>> 12) & 0x0F;
3227 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3228 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3231 reg
[15].I
&= 0xFFFFFFFC;
3232 armNextPC
= reg
[15].I
;
3235 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3237 clockTicks
+= 3 + dataTicksAccess16(address
) +
3238 codeTicksAccess32(armNextPC
);
3243 // LDRSB Rd, [Rn, #offset]!
3244 if (!busPrefetchCount
)
3245 busPrefetch
= busPrefetchEnable
;
3246 int base
= (opcode
>> 16) & 0x0F;
3247 int dest
= (opcode
>> 12) & 0x0F;
3248 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3249 reg
[dest
].I
= (s8
)CPUReadByte(address
);
3251 reg
[base
].I
= address
;
3254 reg
[15].I
&= 0xFFFFFFFC;
3255 armNextPC
= reg
[15].I
;
3258 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3260 clockTicks
+= 3 + dataTicksAccess16(address
) +
3261 codeTicksAccess32(armNextPC
);
3267 // LDRSH Rd, [Rn], -Rm
3268 if (!busPrefetchCount
)
3269 busPrefetch
= busPrefetchEnable
;
3270 int base
= (opcode
>> 16) & 0x0F;
3271 int dest
= (opcode
>> 12) & 0x0F;
3272 u32 address
= reg
[base
].I
;
3273 int offset
= reg
[opcode
& 0x0F].I
;
3274 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3277 reg
[base
].I
= address
;
3281 reg
[15].I
&= 0xFFFFFFFC;
3282 armNextPC
= reg
[15].I
;
3285 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3287 clockTicks
+= 3 + dataTicksAccess16(address
) +
3288 codeTicksAccess32(armNextPC
);
3294 // LDRSH Rd, [Rn], #-offset
3295 if (!busPrefetchCount
)
3296 busPrefetch
= busPrefetchEnable
;
3297 int base
= (opcode
>> 16) & 0x0F;
3298 int dest
= (opcode
>> 12) & 0x0F;
3299 u32 address
= reg
[base
].I
;
3300 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
3301 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3304 reg
[base
].I
= address
;
3308 reg
[15].I
&= 0xFFFFFFFC;
3309 armNextPC
= reg
[15].I
;
3312 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3314 clockTicks
+= 3 + dataTicksAccess16(address
) +
3315 codeTicksAccess32(armNextPC
);
3321 // LDRSH Rd, [Rn], Rm
3322 if (!busPrefetchCount
)
3323 busPrefetch
= busPrefetchEnable
;
3324 int base
= (opcode
>> 16) & 0x0F;
3325 int dest
= (opcode
>> 12) & 0x0F;
3326 u32 address
= reg
[base
].I
;
3327 int offset
= reg
[opcode
& 0x0F].I
;
3328 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3331 reg
[base
].I
= address
;
3335 reg
[15].I
&= 0xFFFFFFFC;
3336 armNextPC
= reg
[15].I
;
3339 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3341 clockTicks
+= 3 + dataTicksAccess16(address
) +
3342 codeTicksAccess32(armNextPC
);
3348 // LDRSH Rd, [Rn], #offset
3349 if (!busPrefetchCount
)
3350 busPrefetch
= busPrefetchEnable
;
3351 int base
= (opcode
>> 16) & 0x0F;
3352 int dest
= (opcode
>> 12) & 0x0F;
3353 u32 address
= reg
[base
].I
;
3354 int offset
= (opcode
& 0x0F) | ((opcode
>> 4) & 0xF0);
3355 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3358 reg
[base
].I
= address
;
3362 reg
[15].I
&= 0xFFFFFFFC;
3363 armNextPC
= reg
[15].I
;
3366 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3368 clockTicks
+= 3 + dataTicksAccess16(address
) +
3369 codeTicksAccess32(armNextPC
);
3374 // LDRSH Rd, [Rn, -Rm]
3375 if (!busPrefetchCount
)
3376 busPrefetch
= busPrefetchEnable
;
3377 int base
= (opcode
>> 16) & 0x0F;
3378 int dest
= (opcode
>> 12) & 0x0F;
3379 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
3380 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3383 reg
[15].I
&= 0xFFFFFFFC;
3384 armNextPC
= reg
[15].I
;
3387 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3389 clockTicks
+= 3 + dataTicksAccess16(address
) +
3390 codeTicksAccess32(armNextPC
);
3395 // LDRSH Rd, [Rn, -Rm]!
3396 if (!busPrefetchCount
)
3397 busPrefetch
= busPrefetchEnable
;
3398 int base
= (opcode
>> 16) & 0x0F;
3399 int dest
= (opcode
>> 12) & 0x0F;
3400 u32 address
= reg
[base
].I
- reg
[opcode
& 0x0F].I
;
3401 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3403 reg
[base
].I
= address
;
3406 reg
[15].I
&= 0xFFFFFFFC;
3407 armNextPC
= reg
[15].I
;
3410 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3412 clockTicks
+= 3 + dataTicksAccess16(address
) +
3413 codeTicksAccess32(armNextPC
);
3418 // LDRSH Rd, [Rn, -#offset]
3419 if (!busPrefetchCount
)
3420 busPrefetch
= busPrefetchEnable
;
3421 int base
= (opcode
>> 16) & 0x0F;
3422 int dest
= (opcode
>> 12) & 0x0F;
3423 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3424 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3427 reg
[15].I
&= 0xFFFFFFFC;
3428 armNextPC
= reg
[15].I
;
3431 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3433 clockTicks
+= 3 + dataTicksAccess16(address
) +
3434 codeTicksAccess32(armNextPC
);
3439 // LDRSH Rd, [Rn, -#offset]!
3440 if (!busPrefetchCount
)
3441 busPrefetch
= busPrefetchEnable
;
3442 int base
= (opcode
>> 16) & 0x0F;
3443 int dest
= (opcode
>> 12) & 0x0F;
3444 u32 address
= reg
[base
].I
- ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3445 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3447 reg
[base
].I
= address
;
3450 reg
[15].I
&= 0xFFFFFFFC;
3451 armNextPC
= reg
[15].I
;
3454 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3456 clockTicks
+= 3 + dataTicksAccess16(address
) +
3457 codeTicksAccess32(armNextPC
);
3462 // LDRSH Rd, [Rn, Rm]
3463 if (!busPrefetchCount
)
3464 busPrefetch
= busPrefetchEnable
;
3465 int base
= (opcode
>> 16) & 0x0F;
3466 int dest
= (opcode
>> 12) & 0x0F;
3467 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
3468 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3471 reg
[15].I
&= 0xFFFFFFFC;
3472 armNextPC
= reg
[15].I
;
3475 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3477 clockTicks
+= 3 + dataTicksAccess16(address
) +
3478 codeTicksAccess32(armNextPC
);
3483 // LDRSH Rd, [Rn, Rm]!
3484 if (!busPrefetchCount
)
3485 busPrefetch
= busPrefetchEnable
;
3486 int base
= (opcode
>> 16) & 0x0F;
3487 int dest
= (opcode
>> 12) & 0x0F;
3488 u32 address
= reg
[base
].I
+ reg
[opcode
& 0x0F].I
;
3489 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3491 reg
[base
].I
= address
;
3494 reg
[15].I
&= 0xFFFFFFFC;
3495 armNextPC
= reg
[15].I
;
3498 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3500 clockTicks
+= 3 + dataTicksAccess16(address
) +
3501 codeTicksAccess32(armNextPC
);
3506 // LDRSH Rd, [Rn, #offset]
3507 if (!busPrefetchCount
)
3508 busPrefetch
= busPrefetchEnable
;
3509 int base
= (opcode
>> 16) & 0x0F;
3510 int dest
= (opcode
>> 12) & 0x0F;
3511 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3512 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3515 reg
[15].I
&= 0xFFFFFFFC;
3516 armNextPC
= reg
[15].I
;
3519 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3521 clockTicks
+= 3 + dataTicksAccess16(address
) +
3522 codeTicksAccess32(armNextPC
);
3527 // LDRSH Rd, [Rn, #offset]!
3528 if (!busPrefetchCount
)
3529 busPrefetch
= busPrefetchEnable
;
3530 int base
= (opcode
>> 16) & 0x0F;
3531 int dest
= (opcode
>> 12) & 0x0F;
3532 u32 address
= reg
[base
].I
+ ((opcode
& 0x0F)|((opcode
>>4)&0xF0));
3533 reg
[dest
].I
= (s16
)CPUReadHalfWordSigned(address
);
3535 reg
[base
].I
= address
;
3538 reg
[15].I
&= 0xFFFFFFFC;
3539 armNextPC
= reg
[15].I
;
3542 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
3544 clockTicks
+= 3 + dataTicksAccess16(address
) +
3545 codeTicksAccess32(armNextPC
);
3548 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EOR
, OP_EOR
, 0x020);
3549 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_EORS
, OP_EOR
, 0x030);
3552 // MLA Rd, Rm, Rs, Rn
3554 int dest
= (opcode
>> 16) & 0x0F;
3555 int mult
= (opcode
& 0x0F);
3556 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3557 reg
[dest
].I
= reg
[mult
].I
* rs
+ reg
[(opcode
>>12)&0x0f].I
;
3558 if((rs
& 0xFFFFFF00) == 0)
3560 else if ((rs
& 0xFFFF0000) == 0)
3562 else if ((rs
& 0xFF000000) == 0)
3566 if (!busPrefetchCount
)
3567 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3568 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3573 // MLAS Rd, Rm, Rs, Rn
3575 int dest
= (opcode
>> 16) & 0x0F;
3576 int mult
= (opcode
& 0x0F);
3577 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3578 reg
[dest
].I
= reg
[mult
].I
* rs
+ reg
[(opcode
>>12)&0x0f].I
;
3579 N_FLAG
= (reg
[dest
].I
& 0x80000000) ? true : false;
3580 Z_FLAG
= (reg
[dest
].I
) ? false : true;
3583 if((rs
& 0xFFFFFF00) == 0)
3585 else if ((rs
& 0xFFFF0000) == 0)
3587 else if ((rs
& 0xFF000000) == 0)
3591 if (!busPrefetchCount
)
3592 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3593 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3596 ARITHMETIC_DATA_OPCODE(OP_SUB
, OP_SUB
, 0x040);
3597 ARITHMETIC_DATA_OPCODE(OP_SUBS
, OP_SUB
, 0x050);
3598 ARITHMETIC_DATA_OPCODE(OP_RSB
, OP_RSB
, 0x060);
3599 ARITHMETIC_DATA_OPCODE(OP_RSBS
, OP_RSB
, 0x070);
3600 ARITHMETIC_DATA_OPCODE(OP_ADD
, OP_ADD
, 0x080);
3601 ARITHMETIC_DATA_OPCODE(OP_ADDS
, OP_ADD
, 0x090);
3604 // UMULL RdLo, RdHi, Rn, Rs
3606 u32 umult
= reg
[(opcode
& 0x0F)].I
;
3607 u32 usource
= reg
[(opcode
>> 8) & 0x0F].I
;
3608 int destLo
= (opcode
>> 12) & 0x0F;
3609 int destHi
= (opcode
>> 16) & 0x0F;
3610 u64 uTemp
= ((u64
)umult
)*((u64
)usource
);
3611 reg
[destLo
].I
= (u32
)uTemp
;
3612 reg
[destHi
].I
= (u32
)(uTemp
>> 32);
3613 if ((usource
& 0xFFFFFF00) == 0)
3615 else if ((usource
& 0xFFFF0000) == 0)
3617 else if ((usource
& 0xFF000000) == 0)
3621 if (!busPrefetchCount
)
3622 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3623 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3628 // UMULLS RdLo, RdHi, Rn, Rs
3630 u32 umult
= reg
[(opcode
& 0x0F)].I
;
3631 u32 usource
= reg
[(opcode
>> 8) & 0x0F].I
;
3632 int destLo
= (opcode
>> 12) & 0x0F;
3633 int destHi
= (opcode
>> 16) & 0x0F;
3634 u64 uTemp
= ((u64
)umult
)*((u64
)usource
);
3635 reg
[destLo
].I
= (u32
)uTemp
;
3636 reg
[destHi
].I
= (u32
)(uTemp
>> 32);
3637 Z_FLAG
= (uTemp
) ? false : true;
3638 N_FLAG
= (reg
[destHi
].I
& 0x80000000) ? true : false;
3639 if ((usource
& 0xFFFFFF00) == 0)
3641 else if ((usource
& 0xFFFF0000) == 0)
3643 else if ((usource
& 0xFF000000) == 0)
3647 if (!busPrefetchCount
)
3648 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3649 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3652 ARITHMETIC_DATA_OPCODE(OP_ADC
, OP_ADC
, 0x0a0);
3653 ARITHMETIC_DATA_OPCODE(OP_ADCS
, OP_ADC
, 0x0b0);
3656 // UMLAL RdLo, RdHi, Rn, Rs
3658 u32 umult
= reg
[(opcode
& 0x0F)].I
;
3659 u32 usource
= reg
[(opcode
>> 8) & 0x0F].I
;
3660 int destLo
= (opcode
>> 12) & 0x0F;
3661 int destHi
= (opcode
>> 16) & 0x0F;
3662 u64 uTemp
= (u64
)reg
[destHi
].I
;
3664 uTemp
|= (u64
)reg
[destLo
].I
;
3665 uTemp
+= ((u64
)umult
)*((u64
)usource
);
3666 reg
[destLo
].I
= (u32
)uTemp
;
3667 reg
[destHi
].I
= (u32
)(uTemp
>> 32);
3668 if ((usource
& 0xFFFFFF00) == 0)
3670 else if ((usource
& 0xFFFF0000) == 0)
3672 else if ((usource
& 0xFF000000) == 0)
3676 if (!busPrefetchCount
)
3677 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3678 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3683 // UMLALS RdLo, RdHi, Rn, Rs
3685 u32 umult
= reg
[(opcode
& 0x0F)].I
;
3686 u32 usource
= reg
[(opcode
>> 8) & 0x0F].I
;
3687 int destLo
= (opcode
>> 12) & 0x0F;
3688 int destHi
= (opcode
>> 16) & 0x0F;
3689 u64 uTemp
= (u64
)reg
[destHi
].I
;
3691 uTemp
|= (u64
)reg
[destLo
].I
;
3692 uTemp
+= ((u64
)umult
)*((u64
)usource
);
3693 reg
[destLo
].I
= (u32
)uTemp
;
3694 reg
[destHi
].I
= (u32
)(uTemp
>> 32);
3695 Z_FLAG
= (uTemp
) ? false : true;
3696 N_FLAG
= (reg
[destHi
].I
& 0x80000000) ? true : false;
3697 if ((usource
& 0xFFFFFF00) == 0)
3699 else if ((usource
& 0xFFFF0000) == 0)
3701 else if ((usource
& 0xFF000000) == 0)
3705 if (!busPrefetchCount
)
3706 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3707 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3710 ARITHMETIC_DATA_OPCODE(OP_SBC
, OP_SBC
, 0x0c0);
3711 ARITHMETIC_DATA_OPCODE(OP_SBCS
, OP_SBC
, 0x0d0);
3714 // SMULL RdLo, RdHi, Rm, Rs
3716 int destLo
= (opcode
>> 12) & 0x0F;
3717 int destHi
= (opcode
>> 16) & 0x0F;
3718 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3719 s64 m
= (s32
)reg
[(opcode
& 0x0F)].I
;
3722 reg
[destLo
].I
= (u32
)sTemp
;
3723 reg
[destHi
].I
= (u32
)(sTemp
>> 32);
3726 if((rs
& 0xFFFFFF00) == 0)
3728 else if((rs
& 0xFFFF0000) == 0)
3730 else if((rs
& 0xFF000000) == 0)
3734 if (!busPrefetchCount
)
3735 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3736 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3741 // SMULLS RdLo, RdHi, Rm, Rs
3743 int destLo
= (opcode
>> 12) & 0x0F;
3744 int destHi
= (opcode
>> 16) & 0x0F;
3745 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3746 s64 m
= (s32
)reg
[(opcode
& 0x0F)].I
;
3749 reg
[destLo
].I
= (u32
)sTemp
;
3750 reg
[destHi
].I
= (u32
)(sTemp
>> 32);
3751 Z_FLAG
= (sTemp
) ? false : true;
3752 N_FLAG
= (sTemp
< 0) ? true : false;
3755 if((rs
& 0xFFFFFF00) == 0)
3757 else if((rs
& 0xFFFF0000) == 0)
3759 else if((rs
& 0xFF000000) == 0)
3763 if (!busPrefetchCount
)
3764 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3765 clockTicks
+= codeTicksAccess32(armNextPC
) + 1;
3768 ARITHMETIC_DATA_OPCODE(OP_RSC
, OP_RSC
, 0x0e0);
3769 ARITHMETIC_DATA_OPCODE(OP_RSCS
, OP_RSC
, 0x0f0);
3772 // SMLAL RdLo, RdHi, Rm, Rs
3773 clockTicks
= codeTicksAccess32(armNextPC
) + 4;
3774 int destLo
= (opcode
>> 12) & 0x0F;
3775 int destHi
= (opcode
>> 16) & 0x0F;
3776 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3777 s64 m
= (s32
)reg
[(opcode
& 0x0F)].I
;
3779 s64 sTemp
= (u64
)reg
[destHi
].I
;
3781 sTemp
|= (u64
)reg
[destLo
].I
;
3783 reg
[destLo
].I
= (u32
)sTemp
;
3784 reg
[destHi
].I
= (u32
)(sTemp
>> 32);
3787 if((rs
& 0xFFFFFF00) == 0)
3789 else if((rs
& 0xFFFF0000) == 0)
3791 else if((rs
& 0xFF000000) == 0)
3795 if (!busPrefetchCount
)
3796 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3801 // SMLALS RdLo, RdHi, Rm, Rs
3802 clockTicks
= codeTicksAccess32(armNextPC
) + 4;
3803 int destLo
= (opcode
>> 12) & 0x0F;
3804 int destHi
= (opcode
>> 16) & 0x0F;
3805 u32 rs
= reg
[(opcode
>> 8) & 0x0F].I
;
3806 s64 m
= (s32
)reg
[(opcode
& 0x0F)].I
;
3808 s64 sTemp
= (u64
)reg
[destHi
].I
;
3810 sTemp
|= (u64
)reg
[destLo
].I
;
3812 reg
[destLo
].I
= (u32
)sTemp
;
3813 reg
[destHi
].I
= (u32
)(sTemp
>> 32);
3814 Z_FLAG
= (sTemp
) ? false : true;
3815 N_FLAG
= (sTemp
< 0) ? true : false;
3818 if((rs
& 0xFFFFFF00) == 0)
3820 else if((rs
& 0xFFFF0000) == 0)
3822 else if((rs
& 0xFF000000) == 0)
3826 if (!busPrefetchCount
)
3827 busPrefetchCount
= ((++busPrefetchCount
)<<clockTicks
) - 1;
3830 LOGICAL_DATA_OPCODE(OP_TST
, OP_TST
, 0x110);
3833 // TODO: check if right instruction....
3835 reg
[(opcode
>> 12) & 0x0F].I
= reg
[16].I
;
3840 u32 address
= reg
[(opcode
>> 16) & 15].I
;
3841 u32 temp
= CPUReadMemory(address
);
3842 CPUWriteMemory(address
, reg
[opcode
&15].I
);
3843 reg
[(opcode
>> 12) & 15].I
= temp
;
3844 clockTicks
= 4 + dataTicksAccess32(address
) + dataTicksAccess32(address
) +
3845 codeTicksAccess32(armNextPC
);
3848 LOGICAL_DATA_OPCODE(OP_TEQ
, OP_TEQ
, 0x130);
3851 // MSR CPSR_fields, Rm
3853 u32 value
= reg
[opcode
& 15].I
;
3854 u32 newValue
= reg
[16].I
;
3855 if(armMode
> 0x10) {
3856 if(opcode
& 0x00010000)
3857 newValue
= (newValue
& 0xFFFFFF00) | (value
& 0x000000FF);
3858 if(opcode
& 0x00020000)
3859 newValue
= (newValue
& 0xFFFF00FF) | (value
& 0x0000FF00);
3860 if(opcode
& 0x00040000)
3861 newValue
= (newValue
& 0xFF00FFFF) | (value
& 0x00FF0000);
3863 if(opcode
& 0x00080000)
3864 newValue
= (newValue
& 0x00FFFFFF) | (value
& 0xFF000000);
3866 CPUSwitchMode(newValue
& 0x1f, false);
3867 reg
[16].I
= newValue
;
3869 if(!armState
) { // this should not be allowed, but it seems to work
3871 reg
[15].I
= armNextPC
+ 2;
3878 // TODO: check if right instruction...
3879 int base
= opcode
& 0x0F;
3881 armState
= reg
[base
].I
& 1 ? false : true;
3883 reg
[15].I
= reg
[base
].I
& 0xFFFFFFFC;
3884 armNextPC
= reg
[15].I
;
3887 clockTicks
= codeTicksAccessSeq32(armNextPC
) +
3888 codeTicksAccessSeq32(armNextPC
) + codeTicksAccess32(armNextPC
) + 3;
3890 reg
[15].I
= reg
[base
].I
& 0xFFFFFFFE;
3891 armNextPC
= reg
[15].I
;
3894 clockTicks
= codeTicksAccessSeq16(armNextPC
) +
3895 codeTicksAccessSeq16(armNextPC
) + codeTicksAccess16(armNextPC
) + 3;
3899 ARITHMETIC_DATA_OPCODE(OP_CMP
, OP_CMP
, 0x150);
3902 // TODO: check if right instruction...
3903 reg
[(opcode
>> 12) & 0x0F].I
= reg
[17].I
;
3907 // SWPB Rd, Rm, [Rn]
3908 u32 address
= reg
[(opcode
>> 16) & 15].I
;
3909 u32 temp
= CPUReadByte(address
);
3910 CPUWriteByte(address
, reg
[opcode
&15].B
.B0
);
3911 reg
[(opcode
>>12)&15].I
= temp
;
3912 clockTicks
= 4 + dataTicksAccess32(address
) + dataTicksAccess32(address
) +
3913 codeTicksAccess32(armNextPC
);
3916 ARITHMETIC_DATA_OPCODE(OP_CMN
, OP_CMN
, 0x170);
3919 // MSR SPSR_fields, Rm
3920 u32 value
= reg
[opcode
& 15].I
;
3921 if(armMode
> 0x10 && armMode
< 0x1f) {
3922 if(opcode
& 0x00010000)
3923 reg
[17].I
= (reg
[17].I
& 0xFFFFFF00) | (value
& 0x000000FF);
3924 if(opcode
& 0x00020000)
3925 reg
[17].I
= (reg
[17].I
& 0xFFFF00FF) | (value
& 0x0000FF00);
3926 if(opcode
& 0x00040000)
3927 reg
[17].I
= (reg
[17].I
& 0xFF00FFFF) | (value
& 0x00FF0000);
3928 if(opcode
& 0x00080000)
3929 reg
[17].I
= (reg
[17].I
& 0x00FFFFFF) | (value
& 0xFF000000);
3933 LOGICAL_DATA_OPCODE (OP_ORR
, OP_ORR
, 0x180);
3934 LOGICAL_DATA_OPCODE (OP_ORRS
, OP_ORR
, 0x190);
3935 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOV
, OP_MOV
, 0x1a0);
3936 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MOVS
, OP_MOV
, 0x1b0);
3937 LOGICAL_DATA_OPCODE (OP_BIC
, OP_BIC
, 0x1c0);
3938 LOGICAL_DATA_OPCODE (OP_BICS
, OP_BIC
, 0x1d0);
3939 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVN
, OP_MVN
, 0x1e0);
3940 LOGICAL_DATA_OPCODE_WITHOUT_base(OP_MVNS
, OP_MVN
, 0x1f0);
3943 case 0x7ff: // for GDB support
3944 extern void (*dbgSignal
)(int,int);
3947 dbgSignal(5, (opcode
& 0x0f)|((opcode
>>4) & 0xfff0));
3967 // MSR CPSR_fields, #
3969 u32 value
= opcode
& 0xFF;
3970 int shift
= (opcode
& 0xF00) >> 7;
3974 u32 newValue
= reg
[16].I
;
3975 if(armMode
> 0x10) {
3976 if(opcode
& 0x00010000)
3977 newValue
= (newValue
& 0xFFFFFF00) | (value
& 0x000000FF);
3978 if(opcode
& 0x00020000)
3979 newValue
= (newValue
& 0xFFFF00FF) | (value
& 0x0000FF00);
3980 if(opcode
& 0x00040000)
3981 newValue
= (newValue
& 0xFF00FFFF) | (value
& 0x00FF0000);
3983 if(opcode
& 0x00080000)
3984 newValue
= (newValue
& 0x00FFFFFF) | (value
& 0xFF000000);
3988 CPUSwitchMode(newValue
& 0x1f, false);
3989 reg
[16].I
= newValue
;
3991 if(!armState
) { // this should not be allowed, but it seems to work
3993 reg
[15].I
= armNextPC
+ 2;
4014 // MSR SPSR_fields, #
4015 if(armMode
> 0x10 && armMode
< 0x1f) {
4016 u32 value
= opcode
& 0xFF;
4017 int shift
= (opcode
& 0xF00) >> 7;
4021 if(opcode
& 0x00010000)
4022 reg
[17].I
= (reg
[17].I
& 0xFFFFFF00) | (value
& 0x000000FF);
4023 if(opcode
& 0x00020000)
4024 reg
[17].I
= (reg
[17].I
& 0xFFFF00FF) | (value
& 0x0000FF00);
4025 if(opcode
& 0x00040000)
4026 reg
[17].I
= (reg
[17].I
& 0xFF00FFFF) | (value
& 0x00FF0000);
4027 if(opcode
& 0x00080000)
4028 reg
[17].I
= (reg
[17].I
& 0x00FFFFFF) | (value
& 0xFF000000);
4033 // T versions shouldn't be different on GBA
4037 if (!busPrefetchCount
)
4038 busPrefetch
= busPrefetchEnable
;
4039 int offset
= opcode
& 0xFFF;
4040 int dest
= (opcode
>> 12) & 15;
4041 int base
= (opcode
>> 16) & 15;
4042 u32 address
= reg
[base
].I
;
4043 CPUWriteMemory(address
, reg
[dest
].I
);
4044 reg
[base
].I
= address
- offset
;
4045 clockTicks
= 2 + dataTicksAccess32(address
) +
4046 codeTicksAccess32(armNextPC
);
4050 // T versions shouldn't be different on GBA
4054 if (!busPrefetchCount
)
4055 busPrefetch
= busPrefetchEnable
;
4056 int offset
= opcode
& 0xFFF;
4057 int dest
= (opcode
>> 12) & 15;
4058 int base
= (opcode
>> 16) & 15;
4059 u32 address
= reg
[base
].I
;
4060 CPUWriteMemory(address
, reg
[dest
].I
);
4061 reg
[base
].I
= address
+ offset
;
4062 clockTicks
= 2 + dataTicksAccess32(address
) +
4063 codeTicksAccess32(armNextPC
);
4069 if (!busPrefetchCount
)
4070 busPrefetch
= busPrefetchEnable
;
4071 int offset
= opcode
& 0xFFF;
4072 int dest
= (opcode
>> 12) & 15;
4073 int base
= (opcode
>> 16) & 15;
4074 u32 address
= reg
[base
].I
- offset
;
4075 CPUWriteMemory(address
, reg
[dest
].I
);
4076 clockTicks
= 2 + dataTicksAccess32(address
) +
4077 codeTicksAccess32(armNextPC
);
4082 // STR Rd, [Rn, -#]!
4083 if (!busPrefetchCount
)
4084 busPrefetch
= busPrefetchEnable
;
4085 int offset
= opcode
& 0xFFF;
4086 int dest
= (opcode
>> 12) & 15;
4087 int base
= (opcode
>> 16) & 15;
4088 u32 address
= reg
[base
].I
- offset
;
4089 reg
[base
].I
= address
;
4090 CPUWriteMemory(address
, reg
[dest
].I
);
4091 clockTicks
= 2 + dataTicksAccess32(address
) +
4092 codeTicksAccess32(armNextPC
);
4098 if (!busPrefetchCount
)
4099 busPrefetch
= busPrefetchEnable
;
4100 int offset
= opcode
& 0xFFF;
4101 int dest
= (opcode
>> 12) & 15;
4102 int base
= (opcode
>> 16) & 15;
4103 u32 address
= reg
[base
].I
+ offset
;
4104 CPUWriteMemory(address
, reg
[dest
].I
);
4105 clockTicks
= 2 + dataTicksAccess32(address
) +
4106 codeTicksAccess32(armNextPC
);
4112 if (!busPrefetchCount
)
4113 busPrefetch
= busPrefetchEnable
;
4114 int offset
= opcode
& 0xFFF;
4115 int dest
= (opcode
>> 12) & 15;
4116 int base
= (opcode
>> 16) & 15;
4117 u32 address
= reg
[base
].I
+ offset
;
4118 reg
[base
].I
= address
;
4119 CPUWriteMemory(address
, reg
[dest
].I
);
4120 clockTicks
= 2 + dataTicksAccess32(address
) +
4121 codeTicksAccess32(armNextPC
);
4127 if (!busPrefetchCount
)
4128 busPrefetch
= busPrefetchEnable
;
4129 int offset
= opcode
& 0xFFF;
4130 int dest
= (opcode
>> 12) & 15;
4131 int base
= (opcode
>> 16) & 15;
4132 u32 address
= reg
[base
].I
;
4133 reg
[dest
].I
= CPUReadMemory(address
);
4135 reg
[base
].I
-= offset
;
4138 reg
[15].I
&= 0xFFFFFFFC;
4139 armNextPC
= reg
[15].I
;
4142 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4144 clockTicks
+= 3 + dataTicksAccess32(address
) +
4145 codeTicksAccess32(armNextPC
);
4150 // LDRT Rd, [Rn], -#
4151 if (!busPrefetchCount
)
4152 busPrefetch
= busPrefetchEnable
;
4153 int offset
= opcode
& 0xFFF;
4154 int dest
= (opcode
>> 12) & 15;
4155 int base
= (opcode
>> 16) & 15;
4156 u32 address
= reg
[base
].I
;
4157 reg
[dest
].I
= CPUReadMemory(address
);
4159 reg
[base
].I
-= offset
;
4162 reg
[15].I
&= 0xFFFFFFFC;
4163 armNextPC
= reg
[15].I
;
4166 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4168 clockTicks
+= 3 + dataTicksAccess32(address
) +
4169 codeTicksAccess32(armNextPC
);
4175 if (!busPrefetchCount
)
4176 busPrefetch
= busPrefetchEnable
;
4177 int offset
= opcode
& 0xFFF;
4178 int dest
= (opcode
>> 12) & 15;
4179 int base
= (opcode
>> 16) & 15;
4180 u32 address
= reg
[base
].I
;
4181 reg
[dest
].I
= CPUReadMemory(address
);
4183 reg
[base
].I
+= offset
;
4186 reg
[15].I
&= 0xFFFFFFFC;
4187 armNextPC
= reg
[15].I
;
4190 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4192 clockTicks
+= 3 + dataTicksAccess32(address
) +
4193 codeTicksAccess32(armNextPC
);
4199 if (!busPrefetchCount
)
4200 busPrefetch
= busPrefetchEnable
;
4201 int offset
= opcode
& 0xFFF;
4202 int dest
= (opcode
>> 12) & 15;
4203 int base
= (opcode
>> 16) & 15;
4204 u32 address
= reg
[base
].I
;
4205 reg
[dest
].I
= CPUReadMemory(address
);
4207 reg
[base
].I
+= offset
;
4210 reg
[15].I
&= 0xFFFFFFFC;
4211 armNextPC
= reg
[15].I
;
4214 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4216 clockTicks
+= 3 + dataTicksAccess32(address
) +
4217 codeTicksAccess32(armNextPC
);
4223 if (!busPrefetchCount
)
4224 busPrefetch
= busPrefetchEnable
;
4225 int offset
= opcode
& 0xFFF;
4226 int dest
= (opcode
>> 12) & 15;
4227 int base
= (opcode
>> 16) & 15;
4228 u32 address
= reg
[base
].I
- offset
;
4229 reg
[dest
].I
= CPUReadMemory(address
);
4232 reg
[15].I
&= 0xFFFFFFFC;
4233 armNextPC
= reg
[15].I
;
4236 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4238 clockTicks
+= 3 + dataTicksAccess32(address
) +
4239 codeTicksAccess32(armNextPC
);
4244 // LDR Rd, [Rn, -#]!
4245 if (!busPrefetchCount
)
4246 busPrefetch
= busPrefetchEnable
;
4247 int offset
= opcode
& 0xFFF;
4248 int dest
= (opcode
>> 12) & 15;
4249 int base
= (opcode
>> 16) & 15;
4250 u32 address
= reg
[base
].I
- offset
;
4251 reg
[dest
].I
= CPUReadMemory(address
);
4253 reg
[base
].I
= address
;
4256 reg
[15].I
&= 0xFFFFFFFC;
4257 armNextPC
= reg
[15].I
;
4260 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4262 clockTicks
+= 3 + dataTicksAccess32(address
) +
4263 codeTicksAccess32(armNextPC
);
4269 if (!busPrefetchCount
)
4270 busPrefetch
= busPrefetchEnable
;
4271 int offset
= opcode
& 0xFFF;
4272 int dest
= (opcode
>> 12) & 15;
4273 int base
= (opcode
>> 16) & 15;
4274 u32 address
= reg
[base
].I
+ offset
;
4275 reg
[dest
].I
= CPUReadMemory(address
);
4278 reg
[15].I
&= 0xFFFFFFFC;
4279 armNextPC
= reg
[15].I
;
4282 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4284 clockTicks
+= 3 + dataTicksAccess32(address
) +
4285 codeTicksAccess32(armNextPC
);
4291 if (!busPrefetchCount
)
4292 busPrefetch
= busPrefetchEnable
;
4293 int offset
= opcode
& 0xFFF;
4294 int dest
= (opcode
>> 12) & 15;
4295 int base
= (opcode
>> 16) & 15;
4296 u32 address
= reg
[base
].I
+ offset
;
4297 reg
[dest
].I
= CPUReadMemory(address
);
4299 reg
[base
].I
= address
;
4302 reg
[15].I
&= 0xFFFFFFFC;
4303 armNextPC
= reg
[15].I
;
4306 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4308 clockTicks
+= 3 + dataTicksAccess32(address
) +
4309 codeTicksAccess32(armNextPC
);
4313 // T versions shouldn't be different on GBA
4316 // STRB Rd, [Rn], -#
4317 if (!busPrefetchCount
)
4318 busPrefetch
= busPrefetchEnable
;
4319 int offset
= opcode
& 0xFFF;
4320 int dest
= (opcode
>> 12) & 15;
4321 int base
= (opcode
>> 16) & 15;
4322 u32 address
= reg
[base
].I
;
4323 CPUWriteByte(address
, reg
[dest
].B
.B0
);
4324 reg
[base
].I
= address
- offset
;
4325 clockTicks
= 2 + dataTicksAccess16(address
) +
4326 codeTicksAccess32(armNextPC
);
4330 // T versions shouldn't be different on GBA
4334 if (!busPrefetchCount
)
4335 busPrefetch
= busPrefetchEnable
;
4336 int offset
= opcode
& 0xFFF;
4337 int dest
= (opcode
>> 12) & 15;
4338 int base
= (opcode
>> 16) & 15;
4339 u32 address
= reg
[base
].I
;
4340 CPUWriteByte(address
, reg
[dest
].B
.B0
);
4341 reg
[base
].I
= address
+ offset
;
4342 clockTicks
= 2 + dataTicksAccess16(address
) +
4343 codeTicksAccess32(armNextPC
);
4348 // STRB Rd, [Rn, -#]
4349 if (!busPrefetchCount
)
4350 busPrefetch
= busPrefetchEnable
;
4351 int offset
= opcode
& 0xFFF;
4352 int dest
= (opcode
>> 12) & 15;
4353 int base
= (opcode
>> 16) & 15;
4354 u32 address
= reg
[base
].I
- offset
;
4355 CPUWriteByte(address
, reg
[dest
].B
.B0
);
4356 clockTicks
= 2 + dataTicksAccess16(address
) +
4357 codeTicksAccess32(armNextPC
);
4362 // STRB Rd, [Rn, -#]!
4363 if (!busPrefetchCount
)
4364 busPrefetch
= busPrefetchEnable
;
4365 int offset
= opcode
& 0xFFF;
4366 int dest
= (opcode
>> 12) & 15;
4367 int base
= (opcode
>> 16) & 15;
4368 u32 address
= reg
[base
].I
- offset
;
4369 reg
[base
].I
= address
;
4370 CPUWriteByte(address
, reg
[dest
].B
.B0
);
4371 clockTicks
= 2 + dataTicksAccess16(address
) +
4372 codeTicksAccess32(armNextPC
);
4378 if (!busPrefetchCount
)
4379 busPrefetch
= busPrefetchEnable
;
4380 int offset
= opcode
& 0xFFF;
4381 int dest
= (opcode
>> 12) & 15;
4382 int base
= (opcode
>> 16) & 15;
4383 u32 address
= reg
[base
].I
+ offset
;
4384 CPUWriteByte(address
, reg
[dest
].B
.B0
);
4385 clockTicks
= 2 + dataTicksAccess16(address
) +
4386 codeTicksAccess32(armNextPC
);
4391 // STRB Rd, [Rn, #]!
4392 if (!busPrefetchCount
)
4393 busPrefetch
= busPrefetchEnable
;
4394 int offset
= opcode
& 0xFFF;
4395 int dest
= (opcode
>> 12) & 15;
4396 int base
= (opcode
>> 16) & 15;
4397 u32 address
= reg
[base
].I
+ offset
;
4398 reg
[base
].I
= address
;
4399 CPUWriteByte(address
, reg
[dest
].I
);
4400 clockTicks
= 2 + dataTicksAccess16(address
) +
4401 codeTicksAccess32(armNextPC
);
4405 // T versions shouldn't be different
4408 // LDRB Rd, [Rn], -#
4409 if (!busPrefetchCount
)
4410 busPrefetch
= busPrefetchEnable
;
4411 int offset
= opcode
& 0xFFF;
4412 int dest
= (opcode
>> 12) & 15;
4413 int base
= (opcode
>> 16) & 15;
4414 u32 address
= reg
[base
].I
;
4415 reg
[dest
].I
= CPUReadByte(address
);
4417 reg
[base
].I
-= offset
;
4420 reg
[15].I
&= 0xFFFFFFFC;
4421 armNextPC
= reg
[15].I
;
4424 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4426 clockTicks
+= 3 + dataTicksAccess16(address
) +
4427 codeTicksAccess32(armNextPC
);
4431 CASE_16(0x4f0) // T versions should not be different
4434 if (!busPrefetchCount
)
4435 busPrefetch
= busPrefetchEnable
;
4436 int offset
= opcode
& 0xFFF;
4437 int dest
= (opcode
>> 12) & 15;
4438 int base
= (opcode
>> 16) & 15;
4439 u32 address
= reg
[base
].I
;
4440 reg
[dest
].I
= CPUReadByte(address
);
4442 reg
[base
].I
+= offset
;
4445 reg
[15].I
&= 0xFFFFFFFC;
4446 armNextPC
= reg
[15].I
;
4449 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4451 clockTicks
+= 3 + dataTicksAccess16(address
) +
4452 codeTicksAccess32(armNextPC
);
4457 // LDRB Rd, [Rn, -#]
4458 if (!busPrefetchCount
)
4459 busPrefetch
= busPrefetchEnable
;
4460 int offset
= opcode
& 0xFFF;
4461 int dest
= (opcode
>> 12) & 15;
4462 int base
= (opcode
>> 16) & 15;
4463 u32 address
= reg
[base
].I
- offset
;
4464 reg
[dest
].I
= CPUReadByte(address
);
4467 reg
[15].I
&= 0xFFFFFFFC;
4468 armNextPC
= reg
[15].I
;
4471 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4473 clockTicks
+= 3 + dataTicksAccess16(address
) +
4474 codeTicksAccess32(armNextPC
);
4479 // LDRB Rd, [Rn, -#]!
4480 if (!busPrefetchCount
)
4481 busPrefetch
= busPrefetchEnable
;
4482 int offset
= opcode
& 0xFFF;
4483 int dest
= (opcode
>> 12) & 15;
4484 int base
= (opcode
>> 16) & 15;
4485 u32 address
= reg
[base
].I
- offset
;
4486 reg
[dest
].I
= CPUReadByte(address
);
4488 reg
[base
].I
= address
;
4491 reg
[15].I
&= 0xFFFFFFFC;
4492 armNextPC
= reg
[15].I
;
4495 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4497 clockTicks
+= 3 + dataTicksAccess16(address
) +
4498 codeTicksAccess32(armNextPC
);
4504 if (!busPrefetchCount
)
4505 busPrefetch
= busPrefetchEnable
;
4506 int offset
= opcode
& 0xFFF;
4507 int dest
= (opcode
>> 12) & 15;
4508 int base
= (opcode
>> 16) & 15;
4509 u32 address
= reg
[base
].I
+ offset
;
4510 reg
[dest
].I
= CPUReadByte(address
);
4513 reg
[15].I
&= 0xFFFFFFFC;
4514 armNextPC
= reg
[15].I
;
4517 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4519 clockTicks
+= 3 + dataTicksAccess16(address
) +
4520 codeTicksAccess32(armNextPC
);
4525 // LDRB Rd, [Rn, #]!
4526 if (!busPrefetchCount
)
4527 busPrefetch
= busPrefetchEnable
;
4528 int offset
= opcode
& 0xFFF;
4529 int dest
= (opcode
>> 12) & 15;
4530 int base
= (opcode
>> 16) & 15;
4531 u32 address
= reg
[base
].I
+ offset
;
4532 reg
[dest
].I
= CPUReadByte(address
);
4534 reg
[base
].I
= address
;
4537 reg
[15].I
&= 0xFFFFFFFC;
4538 armNextPC
= reg
[15].I
;
4541 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
4543 clockTicks
+= 3 + dataTicksAccess16(address
) +
4544 codeTicksAccess32(armNextPC
);
4549 // T versions are the same
4553 // STR Rd, [Rn], -Rm, LSL #
4554 if (!busPrefetchCount
)
4555 busPrefetch
= busPrefetchEnable
;
4556 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4557 int dest
= (opcode
>> 12) & 15;
4558 int base
= (opcode
>> 16) & 15;
4559 u32 address
= reg
[base
].I
;
4560 CPUWriteMemory(address
, reg
[dest
].I
);
4561 reg
[base
].I
= address
- offset
;
4562 clockTicks
= 2 + dataTicksAccess32(address
) +
4563 codeTicksAccess32(armNextPC
);
4568 // T versions are the same
4572 // STR Rd, [Rn], -Rm, LSR #
4573 if (!busPrefetchCount
)
4574 busPrefetch
= busPrefetchEnable
;
4575 int shift
= (opcode
>> 7) & 31;
4576 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4577 int dest
= (opcode
>> 12) & 15;
4578 int base
= (opcode
>> 16) & 15;
4579 u32 address
= reg
[base
].I
;
4580 CPUWriteMemory(address
, reg
[dest
].I
);
4581 reg
[base
].I
= address
- offset
;
4582 clockTicks
= 2 + dataTicksAccess32(address
) +
4583 codeTicksAccess32(armNextPC
);
4588 // T versions are the same
4592 // STR Rd, [Rn], -Rm, ASR #
4593 if (!busPrefetchCount
)
4594 busPrefetch
= busPrefetchEnable
;
4595 int shift
= (opcode
>> 7) & 31;
4598 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4599 else if(reg
[opcode
& 15].I
& 0x80000000)
4600 offset
= 0xFFFFFFFF;
4603 int dest
= (opcode
>> 12) & 15;
4604 int base
= (opcode
>> 16) & 15;
4605 u32 address
= reg
[base
].I
;
4606 CPUWriteMemory(address
, reg
[dest
].I
);
4607 reg
[base
].I
= address
- offset
;
4608 clockTicks
= 2 + dataTicksAccess32(address
) +
4609 codeTicksAccess32(armNextPC
);
4614 // T versions are the same
4618 // STR Rd, [Rn], -Rm, ROR #
4619 if (!busPrefetchCount
)
4620 busPrefetch
= busPrefetchEnable
;
4621 int shift
= (opcode
>> 7) & 31;
4622 u32 value
= reg
[opcode
& 15].I
;
4628 int dest
= (opcode
>> 12) & 15;
4629 int base
= (opcode
>> 16) & 15;
4630 u32 address
= reg
[base
].I
;
4631 CPUWriteMemory(address
, reg
[dest
].I
);
4632 reg
[base
].I
= address
- value
;
4633 clockTicks
= 2 + dataTicksAccess32(address
) +
4634 codeTicksAccess32(armNextPC
);
4639 // T versions are the same
4643 // STR Rd, [Rn], Rm, LSL #
4644 if (!busPrefetchCount
)
4645 busPrefetch
= busPrefetchEnable
;
4646 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4647 int dest
= (opcode
>> 12) & 15;
4648 int base
= (opcode
>> 16) & 15;
4649 u32 address
= reg
[base
].I
;
4650 CPUWriteMemory(address
, reg
[dest
].I
);
4651 reg
[base
].I
= address
+ offset
;
4652 clockTicks
= 2 + dataTicksAccess32(address
) +
4653 codeTicksAccess32(armNextPC
);
4658 // T versions are the same
4662 // STR Rd, [Rn], Rm, LSR #
4663 if (!busPrefetchCount
)
4664 busPrefetch
= busPrefetchEnable
;
4665 int shift
= (opcode
>> 7) & 31;
4666 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4667 int dest
= (opcode
>> 12) & 15;
4668 int base
= (opcode
>> 16) & 15;
4669 u32 address
= reg
[base
].I
;
4670 CPUWriteMemory(address
, reg
[dest
].I
);
4671 reg
[base
].I
= address
+ offset
;
4672 clockTicks
= 2 + dataTicksAccess32(address
) +
4673 codeTicksAccess32(armNextPC
);
4678 // T versions are the same
4682 // STR Rd, [Rn], Rm, ASR #
4683 if (!busPrefetchCount
)
4684 busPrefetch
= busPrefetchEnable
;
4685 int shift
= (opcode
>> 7) & 31;
4688 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4689 else if(reg
[opcode
& 15].I
& 0x80000000)
4690 offset
= 0xFFFFFFFF;
4693 int dest
= (opcode
>> 12) & 15;
4694 int base
= (opcode
>> 16) & 15;
4695 u32 address
= reg
[base
].I
;
4696 CPUWriteMemory(address
, reg
[dest
].I
);
4697 reg
[base
].I
= address
+ offset
;
4698 clockTicks
= 2 + dataTicksAccess32(address
) +
4699 codeTicksAccess32(armNextPC
);
4704 // T versions are the same
4708 // STR Rd, [Rn], Rm, ROR #
4709 if (!busPrefetchCount
)
4710 busPrefetch
= busPrefetchEnable
;
4711 int shift
= (opcode
>> 7) & 31;
4712 u32 value
= reg
[opcode
& 15].I
;
4718 int dest
= (opcode
>> 12) & 15;
4719 int base
= (opcode
>> 16) & 15;
4720 u32 address
= reg
[base
].I
;
4721 CPUWriteMemory(address
, reg
[dest
].I
);
4722 reg
[base
].I
= address
+ value
;
4723 clockTicks
= 2 + dataTicksAccess32(address
) +
4724 codeTicksAccess32(armNextPC
);
4730 // STR Rd, [Rn, -Rm, LSL #]
4731 if (!busPrefetchCount
)
4732 busPrefetch
= busPrefetchEnable
;
4733 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4734 int dest
= (opcode
>> 12) & 15;
4735 int base
= (opcode
>> 16) & 15;
4736 u32 address
= reg
[base
].I
- offset
;
4737 CPUWriteMemory(address
, reg
[dest
].I
);
4738 clockTicks
= 2 + dataTicksAccess32(address
) +
4739 codeTicksAccess32(armNextPC
);
4745 // STR Rd, [Rn, -Rm, LSR #]
4746 if (!busPrefetchCount
)
4747 busPrefetch
= busPrefetchEnable
;
4748 int shift
= (opcode
>> 7) & 31;
4749 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4750 int dest
= (opcode
>> 12) & 15;
4751 int base
= (opcode
>> 16) & 15;
4752 u32 address
= reg
[base
].I
- offset
;
4753 CPUWriteMemory(address
, reg
[dest
].I
);
4754 clockTicks
= 2 + dataTicksAccess32(address
) +
4755 codeTicksAccess32(armNextPC
);
4761 // STR Rd, [Rn, -Rm, ASR #]
4762 if (!busPrefetchCount
)
4763 busPrefetch
= busPrefetchEnable
;
4764 int shift
= (opcode
>> 7) & 31;
4767 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4768 else if(reg
[opcode
& 15].I
& 0x80000000)
4769 offset
= 0xFFFFFFFF;
4772 int dest
= (opcode
>> 12) & 15;
4773 int base
= (opcode
>> 16) & 15;
4774 u32 address
= reg
[base
].I
- offset
;
4775 CPUWriteMemory(address
, reg
[dest
].I
);
4776 clockTicks
= 2 + dataTicksAccess32(address
) +
4777 codeTicksAccess32(armNextPC
);
4783 // STR Rd, [Rn, -Rm, ROR #]
4784 if (!busPrefetchCount
)
4785 busPrefetch
= busPrefetchEnable
;
4786 int shift
= (opcode
>> 7) & 31;
4787 u32 value
= reg
[opcode
& 15].I
;
4793 int dest
= (opcode
>> 12) & 15;
4794 int base
= (opcode
>> 16) & 15;
4795 u32 address
= reg
[base
].I
- value
;
4796 CPUWriteMemory(address
, reg
[dest
].I
);
4797 clockTicks
= 2 + dataTicksAccess32(address
) +
4798 codeTicksAccess32(armNextPC
);
4804 // STR Rd, [Rn, -Rm, LSL #]!
4805 if (!busPrefetchCount
)
4806 busPrefetch
= busPrefetchEnable
;
4807 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4808 int dest
= (opcode
>> 12) & 15;
4809 int base
= (opcode
>> 16) & 15;
4810 u32 address
= reg
[base
].I
- offset
;
4811 reg
[base
].I
= address
;
4812 CPUWriteMemory(address
, reg
[dest
].I
);
4813 clockTicks
= 2 + dataTicksAccess32(address
) +
4814 codeTicksAccess32(armNextPC
);
4820 // STR Rd, [Rn, -Rm, LSR #]!
4821 if (!busPrefetchCount
)
4822 busPrefetch
= busPrefetchEnable
;
4823 int shift
= (opcode
>> 7) & 31;
4824 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4825 int dest
= (opcode
>> 12) & 15;
4826 int base
= (opcode
>> 16) & 15;
4827 u32 address
= reg
[base
].I
- offset
;
4828 reg
[base
].I
= address
;
4829 CPUWriteMemory(address
, reg
[dest
].I
);
4830 clockTicks
= 2 + dataTicksAccess32(address
) +
4831 codeTicksAccess32(armNextPC
);
4837 // STR Rd, [Rn, -Rm, ASR #]!
4838 if (!busPrefetchCount
)
4839 busPrefetch
= busPrefetchEnable
;
4840 int shift
= (opcode
>> 7) & 31;
4843 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4844 else if(reg
[opcode
& 15].I
& 0x80000000)
4845 offset
= 0xFFFFFFFF;
4848 int dest
= (opcode
>> 12) & 15;
4849 int base
= (opcode
>> 16) & 15;
4850 u32 address
= reg
[base
].I
- offset
;
4851 reg
[base
].I
= address
;
4852 CPUWriteMemory(address
, reg
[dest
].I
);
4853 clockTicks
= 2 + dataTicksAccess32(address
) +
4854 codeTicksAccess32(armNextPC
);
4860 // STR Rd, [Rn, -Rm, ROR #]!
4861 if (!busPrefetchCount
)
4862 busPrefetch
= busPrefetchEnable
;
4863 int shift
= (opcode
>> 7) & 31;
4864 u32 value
= reg
[opcode
& 15].I
;
4870 int dest
= (opcode
>> 12) & 15;
4871 int base
= (opcode
>> 16) & 15;
4872 u32 address
= reg
[base
].I
- value
;
4873 reg
[base
].I
= address
;
4874 CPUWriteMemory(address
, reg
[dest
].I
);
4875 clockTicks
= 2 + dataTicksAccess32(address
) +
4876 codeTicksAccess32(armNextPC
);
4882 // STR Rd, [Rn, Rm, LSL #]
4883 if (!busPrefetchCount
)
4884 busPrefetch
= busPrefetchEnable
;
4885 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4886 int dest
= (opcode
>> 12) & 15;
4887 int base
= (opcode
>> 16) & 15;
4888 u32 address
= reg
[base
].I
+ offset
;
4889 CPUWriteMemory(address
, reg
[dest
].I
);
4890 clockTicks
= 2 + dataTicksAccess32(address
) +
4891 codeTicksAccess32(armNextPC
);
4897 // STR Rd, [Rn, Rm, LSR #]
4898 if (!busPrefetchCount
)
4899 busPrefetch
= busPrefetchEnable
;
4900 int shift
= (opcode
>> 7) & 31;
4901 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4902 int dest
= (opcode
>> 12) & 15;
4903 int base
= (opcode
>> 16) & 15;
4904 u32 address
= reg
[base
].I
+ offset
;
4905 CPUWriteMemory(address
, reg
[dest
].I
);
4906 clockTicks
= 2 + dataTicksAccess32(address
) +
4907 codeTicksAccess32(armNextPC
);
4913 // STR Rd, [Rn, Rm, ASR #]
4914 if (!busPrefetchCount
)
4915 busPrefetch
= busPrefetchEnable
;
4916 int shift
= (opcode
>> 7) & 31;
4919 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4920 else if(reg
[opcode
& 15].I
& 0x80000000)
4921 offset
= 0xFFFFFFFF;
4924 int dest
= (opcode
>> 12) & 15;
4925 int base
= (opcode
>> 16) & 15;
4926 u32 address
= reg
[base
].I
+ offset
;
4927 CPUWriteMemory(address
, reg
[dest
].I
);
4928 clockTicks
= 2 + dataTicksAccess32(address
) +
4929 codeTicksAccess32(armNextPC
);
4935 // STR Rd, [Rn, Rm, ROR #]
4936 if (!busPrefetchCount
)
4937 busPrefetch
= busPrefetchEnable
;
4938 int shift
= (opcode
>> 7) & 31;
4939 u32 value
= reg
[opcode
& 15].I
;
4945 int dest
= (opcode
>> 12) & 15;
4946 int base
= (opcode
>> 16) & 15;
4947 u32 address
= reg
[base
].I
+ value
;
4948 CPUWriteMemory(address
, reg
[dest
].I
);
4949 clockTicks
= 2 + dataTicksAccess32(address
) +
4950 codeTicksAccess32(armNextPC
);
4956 // STR Rd, [Rn, Rm, LSL #]!
4957 if (!busPrefetchCount
)
4958 busPrefetch
= busPrefetchEnable
;
4959 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
4960 int dest
= (opcode
>> 12) & 15;
4961 int base
= (opcode
>> 16) & 15;
4962 u32 address
= reg
[base
].I
+ offset
;
4963 reg
[base
].I
= address
;
4964 CPUWriteMemory(address
, reg
[dest
].I
);
4965 clockTicks
= 2 + dataTicksAccess32(address
) +
4966 codeTicksAccess32(armNextPC
);
4972 // STR Rd, [Rn, Rm, LSR #]!
4973 if (!busPrefetchCount
)
4974 busPrefetch
= busPrefetchEnable
;
4975 int shift
= (opcode
>> 7) & 31;
4976 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
4977 int dest
= (opcode
>> 12) & 15;
4978 int base
= (opcode
>> 16) & 15;
4979 u32 address
= reg
[base
].I
+ offset
;
4980 reg
[base
].I
= address
;
4981 CPUWriteMemory(address
, reg
[dest
].I
);
4982 clockTicks
= 2 + dataTicksAccess32(address
) +
4983 codeTicksAccess32(armNextPC
);
4989 // STR Rd, [Rn, Rm, ASR #]!
4990 if (!busPrefetchCount
)
4991 busPrefetch
= busPrefetchEnable
;
4992 int shift
= (opcode
>> 7) & 31;
4995 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
4996 else if(reg
[opcode
& 15].I
& 0x80000000)
4997 offset
= 0xFFFFFFFF;
5000 int dest
= (opcode
>> 12) & 15;
5001 int base
= (opcode
>> 16) & 15;
5002 u32 address
= reg
[base
].I
+ offset
;
5003 reg
[base
].I
= address
;
5004 CPUWriteMemory(address
, reg
[dest
].I
);
5005 clockTicks
= 2 + dataTicksAccess32(address
) +
5006 codeTicksAccess32(armNextPC
);
5012 // STR Rd, [Rn, Rm, ROR #]!
5013 if (!busPrefetchCount
)
5014 busPrefetch
= busPrefetchEnable
;
5015 int shift
= (opcode
>> 7) & 31;
5016 u32 value
= reg
[opcode
& 15].I
;
5022 int dest
= (opcode
>> 12) & 15;
5023 int base
= (opcode
>> 16) & 15;
5024 u32 address
= reg
[base
].I
+ value
;
5025 reg
[base
].I
= address
;
5026 CPUWriteMemory(address
, reg
[dest
].I
);
5027 clockTicks
= 2 + dataTicksAccess32(address
) +
5028 codeTicksAccess32(armNextPC
);
5033 // T versions are the same
5037 // LDR Rd, [Rn], -Rm, LSL #
5038 if (!busPrefetchCount
)
5039 busPrefetch
= busPrefetchEnable
;
5040 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5041 int dest
= (opcode
>> 12) & 15;
5042 int base
= (opcode
>> 16) & 15;
5043 u32 address
= reg
[base
].I
;
5044 reg
[dest
].I
= CPUReadMemory(address
);
5046 reg
[base
].I
= address
- offset
;
5049 reg
[15].I
&= 0xFFFFFFFC;
5050 armNextPC
= reg
[15].I
;
5053 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5055 clockTicks
+= 3 + dataTicksAccess32(address
) +
5056 codeTicksAccess32(armNextPC
);
5061 // T versions are the same
5065 // LDR Rd, [Rn], -Rm, LSR #
5066 if (!busPrefetchCount
)
5067 busPrefetch
= busPrefetchEnable
;
5068 int shift
= (opcode
>> 7) & 31;
5069 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5070 int dest
= (opcode
>> 12) & 15;
5071 int base
= (opcode
>> 16) & 15;
5072 u32 address
= reg
[base
].I
;
5073 reg
[dest
].I
= CPUReadMemory(address
);
5075 reg
[base
].I
= address
- offset
;
5078 reg
[15].I
&= 0xFFFFFFFC;
5079 armNextPC
= reg
[15].I
;
5082 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5084 clockTicks
+= 3 + dataTicksAccess32(address
) +
5085 codeTicksAccess32(armNextPC
);
5090 // T versions are the same
5094 // LDR Rd, [Rn], -Rm, ASR #
5095 if (!busPrefetchCount
)
5096 busPrefetch
= busPrefetchEnable
;
5097 int shift
= (opcode
>> 7) & 31;
5100 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5101 else if(reg
[opcode
& 15].I
& 0x80000000)
5102 offset
= 0xFFFFFFFF;
5105 int dest
= (opcode
>> 12) & 15;
5106 int base
= (opcode
>> 16) & 15;
5107 u32 address
= reg
[base
].I
;
5108 reg
[dest
].I
= CPUReadMemory(address
);
5110 reg
[base
].I
= address
- offset
;
5113 reg
[15].I
&= 0xFFFFFFFC;
5114 armNextPC
= reg
[15].I
;
5117 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5119 clockTicks
+= 3 + dataTicksAccess32(address
) +
5120 codeTicksAccess32(armNextPC
);
5125 // T versions are the same
5129 // LDR Rd, [Rn], -Rm, ROR #
5130 if (!busPrefetchCount
)
5131 busPrefetch
= busPrefetchEnable
;
5132 int shift
= (opcode
>> 7) & 31;
5133 u32 value
= reg
[opcode
& 15].I
;
5139 int dest
= (opcode
>> 12) & 15;
5140 int base
= (opcode
>> 16) & 15;
5141 u32 address
= reg
[base
].I
;
5142 reg
[dest
].I
= CPUReadMemory(address
);
5144 reg
[base
].I
= address
- value
;
5147 reg
[15].I
&= 0xFFFFFFFC;
5148 armNextPC
= reg
[15].I
;
5151 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5153 clockTicks
+= 3 + dataTicksAccess32(address
) +
5154 codeTicksAccess32(armNextPC
);
5159 // T versions are the same
5163 // LDR Rd, [Rn], Rm, LSL #
5164 if (!busPrefetchCount
)
5165 busPrefetch
= busPrefetchEnable
;
5166 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5167 int dest
= (opcode
>> 12) & 15;
5168 int base
= (opcode
>> 16) & 15;
5169 u32 address
= reg
[base
].I
;
5170 reg
[dest
].I
= CPUReadMemory(address
);
5172 reg
[base
].I
= address
+ offset
;
5175 reg
[15].I
&= 0xFFFFFFFC;
5176 armNextPC
= reg
[15].I
;
5179 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5181 clockTicks
+= 3 + dataTicksAccess32(address
) +
5182 codeTicksAccess32(armNextPC
);
5187 // T versions are the same
5191 // LDR Rd, [Rn], Rm, LSR #
5192 if (!busPrefetchCount
)
5193 busPrefetch
= busPrefetchEnable
;
5194 int shift
= (opcode
>> 7) & 31;
5195 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5196 int dest
= (opcode
>> 12) & 15;
5197 int base
= (opcode
>> 16) & 15;
5198 u32 address
= reg
[base
].I
;
5199 reg
[dest
].I
= CPUReadMemory(address
);
5201 reg
[base
].I
= address
+ offset
;
5204 reg
[15].I
&= 0xFFFFFFFC;
5205 armNextPC
= reg
[15].I
;
5208 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5210 clockTicks
+= 3 + dataTicksAccess32(address
) +
5211 codeTicksAccess32(armNextPC
);
5216 // T versions are the same
5220 // LDR Rd, [Rn], Rm, ASR #
5221 if (!busPrefetchCount
)
5222 busPrefetch
= busPrefetchEnable
;
5223 int shift
= (opcode
>> 7) & 31;
5226 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5227 else if(reg
[opcode
& 15].I
& 0x80000000)
5228 offset
= 0xFFFFFFFF;
5231 int dest
= (opcode
>> 12) & 15;
5232 int base
= (opcode
>> 16) & 15;
5233 u32 address
= reg
[base
].I
;
5234 reg
[dest
].I
= CPUReadMemory(address
);
5236 reg
[base
].I
= address
+ offset
;
5239 reg
[15].I
&= 0xFFFFFFFC;
5240 armNextPC
= reg
[15].I
;
5243 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5245 clockTicks
+= 3 + dataTicksAccess32(address
) +
5246 codeTicksAccess32(armNextPC
);
5251 // T versions are the same
5255 // LDR Rd, [Rn], Rm, ROR #
5256 if (!busPrefetchCount
)
5257 busPrefetch
= busPrefetchEnable
;
5258 int shift
= (opcode
>> 7) & 31;
5259 u32 value
= reg
[opcode
& 15].I
;
5265 int dest
= (opcode
>> 12) & 15;
5266 int base
= (opcode
>> 16) & 15;
5267 u32 address
= reg
[base
].I
;
5268 reg
[dest
].I
= CPUReadMemory(address
);
5270 reg
[base
].I
= address
+ value
;
5273 reg
[15].I
&= 0xFFFFFFFC;
5274 armNextPC
= reg
[15].I
;
5277 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5279 clockTicks
+= 3 + dataTicksAccess32(address
) +
5280 codeTicksAccess32(armNextPC
);
5286 // LDR Rd, [Rn, -Rm, LSL #]
5287 if (!busPrefetchCount
)
5288 busPrefetch
= busPrefetchEnable
;
5289 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5290 int dest
= (opcode
>> 12) & 15;
5291 int base
= (opcode
>> 16) & 15;
5292 u32 address
= reg
[base
].I
- offset
;
5293 reg
[dest
].I
= CPUReadMemory(address
);
5296 reg
[15].I
&= 0xFFFFFFFC;
5297 armNextPC
= reg
[15].I
;
5300 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5302 clockTicks
+= 3 + dataTicksAccess32(address
) +
5303 codeTicksAccess32(armNextPC
);
5309 // LDR Rd, [Rn, -Rm, LSR #]
5310 if (!busPrefetchCount
)
5311 busPrefetch
= busPrefetchEnable
;
5312 int shift
= (opcode
>> 7) & 31;
5313 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5314 int dest
= (opcode
>> 12) & 15;
5315 int base
= (opcode
>> 16) & 15;
5316 u32 address
= reg
[base
].I
- offset
;
5317 reg
[dest
].I
= CPUReadMemory(address
);
5320 reg
[15].I
&= 0xFFFFFFFC;
5321 armNextPC
= reg
[15].I
;
5324 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5326 clockTicks
+= 3 + dataTicksAccess32(address
) +
5327 codeTicksAccess32(armNextPC
);
5333 // LDR Rd, [Rn, -Rm, ASR #]
5334 if (!busPrefetchCount
)
5335 busPrefetch
= busPrefetchEnable
;
5336 int shift
= (opcode
>> 7) & 31;
5339 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5340 else if(reg
[opcode
& 15].I
& 0x80000000)
5341 offset
= 0xFFFFFFFF;
5344 int dest
= (opcode
>> 12) & 15;
5345 int base
= (opcode
>> 16) & 15;
5346 u32 address
= reg
[base
].I
- offset
;
5347 reg
[dest
].I
= CPUReadMemory(address
);
5350 reg
[15].I
&= 0xFFFFFFFC;
5351 armNextPC
= reg
[15].I
;
5354 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5356 clockTicks
+= 3 + dataTicksAccess32(address
) +
5357 codeTicksAccess32(armNextPC
);
5363 // LDR Rd, [Rn, -Rm, ROR #]
5364 if (!busPrefetchCount
)
5365 busPrefetch
= busPrefetchEnable
;
5366 int shift
= (opcode
>> 7) & 31;
5367 u32 value
= reg
[opcode
& 15].I
;
5373 int dest
= (opcode
>> 12) & 15;
5374 int base
= (opcode
>> 16) & 15;
5375 u32 address
= reg
[base
].I
- value
;
5376 reg
[dest
].I
= CPUReadMemory(address
);
5379 reg
[15].I
&= 0xFFFFFFFC;
5380 armNextPC
= reg
[15].I
;
5383 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5385 clockTicks
+= 3 + dataTicksAccess32(address
) +
5386 codeTicksAccess32(armNextPC
);
5392 // LDR Rd, [Rn, -Rm, LSL #]!
5393 if (!busPrefetchCount
)
5394 busPrefetch
= busPrefetchEnable
;
5395 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5396 int dest
= (opcode
>> 12) & 15;
5397 int base
= (opcode
>> 16) & 15;
5398 u32 address
= reg
[base
].I
- offset
;
5399 reg
[dest
].I
= CPUReadMemory(address
);
5401 reg
[base
].I
= address
;
5404 reg
[15].I
&= 0xFFFFFFFC;
5405 armNextPC
= reg
[15].I
;
5408 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5410 clockTicks
+= 3 + dataTicksAccess32(address
) +
5411 codeTicksAccess32(armNextPC
);
5417 // LDR Rd, [Rn, -Rm, LSR #]!
5418 if (!busPrefetchCount
)
5419 busPrefetch
= busPrefetchEnable
;
5420 int shift
= (opcode
>> 7) & 31;
5421 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5422 int dest
= (opcode
>> 12) & 15;
5423 int base
= (opcode
>> 16) & 15;
5424 u32 address
= reg
[base
].I
- offset
;
5425 reg
[dest
].I
= CPUReadMemory(address
);
5427 reg
[base
].I
= address
;
5430 reg
[15].I
&= 0xFFFFFFFC;
5431 armNextPC
= reg
[15].I
;
5434 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5436 clockTicks
+= 3 + dataTicksAccess32(address
) +
5437 codeTicksAccess32(armNextPC
);
5443 // LDR Rd, [Rn, -Rm, ASR #]!
5444 if (!busPrefetchCount
)
5445 busPrefetch
= busPrefetchEnable
;
5446 int shift
= (opcode
>> 7) & 31;
5449 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5450 else if(reg
[opcode
& 15].I
& 0x80000000)
5451 offset
= 0xFFFFFFFF;
5454 int dest
= (opcode
>> 12) & 15;
5455 int base
= (opcode
>> 16) & 15;
5456 u32 address
= reg
[base
].I
- offset
;
5457 reg
[dest
].I
= CPUReadMemory(address
);
5459 reg
[base
].I
= address
;
5462 reg
[15].I
&= 0xFFFFFFFC;
5463 armNextPC
= reg
[15].I
;
5466 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5468 clockTicks
+= 3 + dataTicksAccess32(address
) +
5469 codeTicksAccess32(armNextPC
);
5475 // LDR Rd, [Rn, -Rm, ROR #]!
5476 if (!busPrefetchCount
)
5477 busPrefetch
= busPrefetchEnable
;
5478 int shift
= (opcode
>> 7) & 31;
5479 u32 value
= reg
[opcode
& 15].I
;
5485 int dest
= (opcode
>> 12) & 15;
5486 int base
= (opcode
>> 16) & 15;
5487 u32 address
= reg
[base
].I
- value
;
5488 reg
[dest
].I
= CPUReadMemory(address
);
5490 reg
[base
].I
= address
;
5493 reg
[15].I
&= 0xFFFFFFFC;
5494 armNextPC
= reg
[15].I
;
5497 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5499 clockTicks
+= 3 + dataTicksAccess32(address
) +
5500 codeTicksAccess32(armNextPC
);
5506 // LDR Rd, [Rn, Rm, LSL #]
5507 if (!busPrefetchCount
)
5508 busPrefetch
= busPrefetchEnable
;
5509 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5510 int dest
= (opcode
>> 12) & 15;
5511 int base
= (opcode
>> 16) & 15;
5512 u32 address
= reg
[base
].I
+ offset
;
5513 reg
[dest
].I
= CPUReadMemory(address
);
5516 reg
[15].I
&= 0xFFFFFFFC;
5517 armNextPC
= reg
[15].I
;
5520 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5522 clockTicks
+= 3 + dataTicksAccess32(address
) +
5523 codeTicksAccess32(armNextPC
);
5529 // LDR Rd, [Rn, Rm, LSR #]
5530 if (!busPrefetchCount
)
5531 busPrefetch
= busPrefetchEnable
;
5532 int shift
= (opcode
>> 7) & 31;
5533 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5534 int dest
= (opcode
>> 12) & 15;
5535 int base
= (opcode
>> 16) & 15;
5536 u32 address
= reg
[base
].I
+ offset
;
5537 reg
[dest
].I
= CPUReadMemory(address
);
5540 reg
[15].I
&= 0xFFFFFFFC;
5541 armNextPC
= reg
[15].I
;
5544 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5546 clockTicks
+= 3 + dataTicksAccess32(address
) +
5547 codeTicksAccess32(armNextPC
);
5553 // LDR Rd, [Rn, Rm, ASR #]
5554 if (!busPrefetchCount
)
5555 busPrefetch
= busPrefetchEnable
;
5556 int shift
= (opcode
>> 7) & 31;
5559 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5560 else if(reg
[opcode
& 15].I
& 0x80000000)
5561 offset
= 0xFFFFFFFF;
5564 int dest
= (opcode
>> 12) & 15;
5565 int base
= (opcode
>> 16) & 15;
5566 u32 address
= reg
[base
].I
+ offset
;
5567 reg
[dest
].I
= CPUReadMemory(address
);
5570 reg
[15].I
&= 0xFFFFFFFC;
5571 armNextPC
= reg
[15].I
;
5574 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5576 clockTicks
+= 3 + dataTicksAccess32(address
) +
5577 codeTicksAccess32(armNextPC
);
5583 // LDR Rd, [Rn, Rm, ROR #]
5584 if (!busPrefetchCount
)
5585 busPrefetch
= busPrefetchEnable
;
5586 int shift
= (opcode
>> 7) & 31;
5587 u32 value
= reg
[opcode
& 15].I
;
5593 int dest
= (opcode
>> 12) & 15;
5594 int base
= (opcode
>> 16) & 15;
5595 u32 address
= reg
[base
].I
+ value
;
5596 reg
[dest
].I
= CPUReadMemory(address
);
5599 reg
[15].I
&= 0xFFFFFFFC;
5600 armNextPC
= reg
[15].I
;
5603 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5605 clockTicks
+= 3 + dataTicksAccess32(address
) +
5606 codeTicksAccess32(armNextPC
);
5612 // LDR Rd, [Rn, Rm, LSL #]!
5613 if (!busPrefetchCount
)
5614 busPrefetch
= busPrefetchEnable
;
5615 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5616 int dest
= (opcode
>> 12) & 15;
5617 int base
= (opcode
>> 16) & 15;
5618 u32 address
= reg
[base
].I
+ offset
;
5619 reg
[dest
].I
= CPUReadMemory(address
);
5621 reg
[base
].I
= address
;
5624 reg
[15].I
&= 0xFFFFFFFC;
5625 armNextPC
= reg
[15].I
;
5628 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5630 clockTicks
+= 3 + dataTicksAccess32(address
) +
5631 codeTicksAccess32(armNextPC
);
5637 // LDR Rd, [Rn, Rm, LSR #]!
5638 if (!busPrefetchCount
)
5639 busPrefetch
= busPrefetchEnable
;
5640 int shift
= (opcode
>> 7) & 31;
5641 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5642 int dest
= (opcode
>> 12) & 15;
5643 int base
= (opcode
>> 16) & 15;
5644 u32 address
= reg
[base
].I
+ offset
;
5645 reg
[dest
].I
= CPUReadMemory(address
);
5647 reg
[base
].I
= address
;
5650 reg
[15].I
&= 0xFFFFFFFC;
5651 armNextPC
= reg
[15].I
;
5654 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5656 clockTicks
+= 3 + dataTicksAccess32(address
) +
5657 codeTicksAccess32(armNextPC
);
5663 // LDR Rd, [Rn, Rm, ASR #]!
5664 if (!busPrefetchCount
)
5665 busPrefetch
= busPrefetchEnable
;
5666 int shift
= (opcode
>> 7) & 31;
5669 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5670 else if(reg
[opcode
& 15].I
& 0x80000000)
5671 offset
= 0xFFFFFFFF;
5674 int dest
= (opcode
>> 12) & 15;
5675 int base
= (opcode
>> 16) & 15;
5676 u32 address
= reg
[base
].I
+ offset
;
5677 reg
[dest
].I
= CPUReadMemory(address
);
5679 reg
[base
].I
= address
;
5682 reg
[15].I
&= 0xFFFFFFFC;
5683 armNextPC
= reg
[15].I
;
5686 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5688 clockTicks
+= 3 + dataTicksAccess32(address
) +
5689 codeTicksAccess32(armNextPC
);
5695 // LDR Rd, [Rn, Rm, ROR #]!
5696 if (!busPrefetchCount
)
5697 busPrefetch
= busPrefetchEnable
;
5698 int shift
= (opcode
>> 7) & 31;
5699 u32 value
= reg
[opcode
& 15].I
;
5705 int dest
= (opcode
>> 12) & 15;
5706 int base
= (opcode
>> 16) & 15;
5707 u32 address
= reg
[base
].I
+ value
;
5708 reg
[dest
].I
= CPUReadMemory(address
);
5710 reg
[base
].I
= address
;
5713 reg
[15].I
&= 0xFFFFFFFC;
5714 armNextPC
= reg
[15].I
;
5717 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
5719 clockTicks
+= 3 + dataTicksAccess32(address
) +
5720 codeTicksAccess32(armNextPC
);
5725 // T versions are the same
5729 // STRB Rd, [Rn], -Rm, LSL #
5730 if (!busPrefetchCount
)
5731 busPrefetch
= busPrefetchEnable
;
5732 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5733 int dest
= (opcode
>> 12) & 15;
5734 int base
= (opcode
>> 16) & 15;
5735 u32 address
= reg
[base
].I
;
5736 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5737 reg
[base
].I
= address
- offset
;
5738 clockTicks
= 2 + dataTicksAccess16(address
) +
5739 codeTicksAccess32(armNextPC
);
5744 // T versions are the same
5748 // STRB Rd, [Rn], -Rm, LSR #
5749 if (!busPrefetchCount
)
5750 busPrefetch
= busPrefetchEnable
;
5751 int shift
= (opcode
>> 7) & 31;
5752 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5753 int dest
= (opcode
>> 12) & 15;
5754 int base
= (opcode
>> 16) & 15;
5755 u32 address
= reg
[base
].I
;
5756 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5757 reg
[base
].I
= address
- offset
;
5758 clockTicks
= 2 + dataTicksAccess16(address
) +
5759 codeTicksAccess32(armNextPC
);
5764 // T versions are the same
5768 // STRB Rd, [Rn], -Rm, ASR #
5769 if (!busPrefetchCount
)
5770 busPrefetch
= busPrefetchEnable
;
5771 int shift
= (opcode
>> 7) & 31;
5774 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5775 else if(reg
[opcode
& 15].I
& 0x80000000)
5776 offset
= 0xFFFFFFFF;
5779 int dest
= (opcode
>> 12) & 15;
5780 int base
= (opcode
>> 16) & 15;
5781 u32 address
= reg
[base
].I
;
5782 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5783 reg
[base
].I
= address
- offset
;
5784 clockTicks
= 2 + dataTicksAccess16(address
) +
5785 codeTicksAccess32(armNextPC
);
5790 // T versions are the same
5794 // STRB Rd, [Rn], -Rm, ROR #
5795 if (!busPrefetchCount
)
5796 busPrefetch
= busPrefetchEnable
;
5797 int shift
= (opcode
>> 7) & 31;
5798 u32 value
= reg
[opcode
& 15].I
;
5804 int dest
= (opcode
>> 12) & 15;
5805 int base
= (opcode
>> 16) & 15;
5806 u32 address
= reg
[base
].I
;
5807 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5808 reg
[base
].I
= address
- value
;
5809 clockTicks
= 2 + dataTicksAccess16(address
) +
5810 codeTicksAccess32(armNextPC
);
5815 // T versions are the same
5819 // STRB Rd, [Rn], Rm, LSL #
5820 if (!busPrefetchCount
)
5821 busPrefetch
= busPrefetchEnable
;
5822 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5823 int dest
= (opcode
>> 12) & 15;
5824 int base
= (opcode
>> 16) & 15;
5825 u32 address
= reg
[base
].I
;
5826 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5827 reg
[base
].I
= address
+ offset
;
5828 clockTicks
= 2 + dataTicksAccess16(address
) +
5829 codeTicksAccess32(armNextPC
);
5834 // T versions are the same
5838 // STRB Rd, [Rn], Rm, LSR #
5839 if (!busPrefetchCount
)
5840 busPrefetch
= busPrefetchEnable
;
5841 int shift
= (opcode
>> 7) & 31;
5842 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5843 int dest
= (opcode
>> 12) & 15;
5844 int base
= (opcode
>> 16) & 15;
5845 u32 address
= reg
[base
].I
;
5846 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5847 reg
[base
].I
= address
+ offset
;
5848 clockTicks
= 2 + dataTicksAccess16(address
) +
5849 codeTicksAccess32(armNextPC
);
5854 // T versions are the same
5858 // STRB Rd, [Rn], Rm, ASR #
5859 if (!busPrefetchCount
)
5860 busPrefetch
= busPrefetchEnable
;
5861 int shift
= (opcode
>> 7) & 31;
5864 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5865 else if(reg
[opcode
& 15].I
& 0x80000000)
5866 offset
= 0xFFFFFFFF;
5869 int dest
= (opcode
>> 12) & 15;
5870 int base
= (opcode
>> 16) & 15;
5871 u32 address
= reg
[base
].I
;
5872 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5873 reg
[base
].I
= address
+ offset
;
5874 clockTicks
= 2 + dataTicksAccess16(address
) +
5875 codeTicksAccess32(armNextPC
);
5880 // T versions are the same
5884 // STRB Rd, [Rn], Rm, ROR #
5885 if (!busPrefetchCount
)
5886 busPrefetch
= busPrefetchEnable
;
5887 int shift
= (opcode
>> 7) & 31;
5888 u32 value
= reg
[opcode
& 15].I
;
5894 int dest
= (opcode
>> 12) & 15;
5895 int base
= (opcode
>> 16) & 15;
5896 u32 address
= reg
[base
].I
;
5897 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5898 reg
[base
].I
= address
+ value
;
5899 clockTicks
= 2 + dataTicksAccess16(address
) +
5900 codeTicksAccess32(armNextPC
);
5906 // STRB Rd, [Rn, -Rm, LSL #]
5907 if (!busPrefetchCount
)
5908 busPrefetch
= busPrefetchEnable
;
5909 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5910 int dest
= (opcode
>> 12) & 15;
5911 int base
= (opcode
>> 16) & 15;
5912 u32 address
= reg
[base
].I
- offset
;
5913 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5914 clockTicks
= 2 + dataTicksAccess16(address
) +
5915 codeTicksAccess32(armNextPC
);
5921 // STRB Rd, [Rn, -Rm, LSR #]
5922 if (!busPrefetchCount
)
5923 busPrefetch
= busPrefetchEnable
;
5924 int shift
= (opcode
>> 7) & 31;
5925 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
5926 int dest
= (opcode
>> 12) & 15;
5927 int base
= (opcode
>> 16) & 15;
5928 u32 address
= reg
[base
].I
- offset
;
5929 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5930 clockTicks
= 2 + dataTicksAccess16(address
) +
5931 codeTicksAccess32(armNextPC
);
5937 // STRB Rd, [Rn, -Rm, ASR #]
5938 if (!busPrefetchCount
)
5939 busPrefetch
= busPrefetchEnable
;
5940 int shift
= (opcode
>> 7) & 31;
5943 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
5944 else if(reg
[opcode
& 15].I
& 0x80000000)
5945 offset
= 0xFFFFFFFF;
5948 int dest
= (opcode
>> 12) & 15;
5949 int base
= (opcode
>> 16) & 15;
5950 u32 address
= reg
[base
].I
- offset
;
5951 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5952 clockTicks
= 2 + dataTicksAccess16(address
) +
5953 codeTicksAccess32(armNextPC
);
5959 // STRB Rd, [Rn, -Rm, ROR #]
5960 if (!busPrefetchCount
)
5961 busPrefetch
= busPrefetchEnable
;
5962 int shift
= (opcode
>> 7) & 31;
5963 u32 value
= reg
[opcode
& 15].I
;
5969 int dest
= (opcode
>> 12) & 15;
5970 int base
= (opcode
>> 16) & 15;
5971 u32 address
= reg
[base
].I
- value
;
5972 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5973 clockTicks
= 2 + dataTicksAccess16(address
) +
5974 codeTicksAccess32(armNextPC
);
5980 // STRB Rd, [Rn, -Rm, LSL #]!
5981 if (!busPrefetchCount
)
5982 busPrefetch
= busPrefetchEnable
;
5983 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
5984 int dest
= (opcode
>> 12) & 15;
5985 int base
= (opcode
>> 16) & 15;
5986 u32 address
= reg
[base
].I
- offset
;
5987 reg
[base
].I
= address
;
5988 CPUWriteByte(address
, reg
[dest
].B
.B0
);
5989 clockTicks
= 2 + dataTicksAccess16(address
) +
5990 codeTicksAccess32(armNextPC
);
5996 // STRB Rd, [Rn, -Rm, LSR #]!
5997 if (!busPrefetchCount
)
5998 busPrefetch
= busPrefetchEnable
;
5999 int shift
= (opcode
>> 7) & 31;
6000 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6001 int dest
= (opcode
>> 12) & 15;
6002 int base
= (opcode
>> 16) & 15;
6003 u32 address
= reg
[base
].I
- offset
;
6004 reg
[base
].I
= address
;
6005 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6006 clockTicks
= 2 + dataTicksAccess16(address
) +
6007 codeTicksAccess32(armNextPC
);
6013 // STRB Rd, [Rn, -Rm, ASR #]!
6014 if (!busPrefetchCount
)
6015 busPrefetch
= busPrefetchEnable
;
6016 int shift
= (opcode
>> 7) & 31;
6019 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6020 else if(reg
[opcode
& 15].I
& 0x80000000)
6021 offset
= 0xFFFFFFFF;
6024 int dest
= (opcode
>> 12) & 15;
6025 int base
= (opcode
>> 16) & 15;
6026 u32 address
= reg
[base
].I
- offset
;
6027 reg
[base
].I
= address
;
6028 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6029 clockTicks
= 2 + dataTicksAccess16(address
) +
6030 codeTicksAccess32(armNextPC
);
6036 // STRB Rd, [Rn, -Rm, ROR #]!
6037 if (!busPrefetchCount
)
6038 busPrefetch
= busPrefetchEnable
;
6039 int shift
= (opcode
>> 7) & 31;
6040 u32 value
= reg
[opcode
& 15].I
;
6046 int dest
= (opcode
>> 12) & 15;
6047 int base
= (opcode
>> 16) & 15;
6048 u32 address
= reg
[base
].I
- value
;
6049 reg
[base
].I
= address
;
6050 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6051 clockTicks
= 2 + dataTicksAccess16(address
) +
6052 codeTicksAccess32(armNextPC
);
6058 // STRB Rd, [Rn, Rm, LSL #]
6059 if (!busPrefetchCount
)
6060 busPrefetch
= busPrefetchEnable
;
6061 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6062 int dest
= (opcode
>> 12) & 15;
6063 int base
= (opcode
>> 16) & 15;
6064 u32 address
= reg
[base
].I
+ offset
;
6065 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6066 clockTicks
= 2 + dataTicksAccess16(address
) +
6067 codeTicksAccess32(armNextPC
);
6073 // STRB Rd, [Rn, Rm, LSR #]
6074 if (!busPrefetchCount
)
6075 busPrefetch
= busPrefetchEnable
;
6076 int shift
= (opcode
>> 7) & 31;
6077 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6078 int dest
= (opcode
>> 12) & 15;
6079 int base
= (opcode
>> 16) & 15;
6080 u32 address
= reg
[base
].I
+ offset
;
6081 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6082 clockTicks
= 2 + dataTicksAccess16(address
) +
6083 codeTicksAccess32(armNextPC
);
6089 // STRB Rd, [Rn, Rm, ASR #]
6090 if (!busPrefetchCount
)
6091 busPrefetch
= busPrefetchEnable
;
6092 int shift
= (opcode
>> 7) & 31;
6095 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6096 else if(reg
[opcode
& 15].I
& 0x80000000)
6097 offset
= 0xFFFFFFFF;
6100 int dest
= (opcode
>> 12) & 15;
6101 int base
= (opcode
>> 16) & 15;
6102 u32 address
= reg
[base
].I
+ offset
;
6103 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6104 clockTicks
= 2 + dataTicksAccess16(address
) +
6105 codeTicksAccess32(armNextPC
);
6111 // STRB Rd, [Rn, Rm, ROR #]
6112 if (!busPrefetchCount
)
6113 busPrefetch
= busPrefetchEnable
;
6114 int shift
= (opcode
>> 7) & 31;
6115 u32 value
= reg
[opcode
& 15].I
;
6121 int dest
= (opcode
>> 12) & 15;
6122 int base
= (opcode
>> 16) & 15;
6123 u32 address
= reg
[base
].I
+ value
;
6124 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6125 clockTicks
= 2 + dataTicksAccess16(address
) +
6126 codeTicksAccess32(armNextPC
);
6132 // STRB Rd, [Rn, Rm, LSL #]!
6133 if (!busPrefetchCount
)
6134 busPrefetch
= busPrefetchEnable
;
6135 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6136 int dest
= (opcode
>> 12) & 15;
6137 int base
= (opcode
>> 16) & 15;
6138 u32 address
= reg
[base
].I
+ offset
;
6139 reg
[base
].I
= address
;
6140 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6141 clockTicks
= 2 + dataTicksAccess16(address
) +
6142 codeTicksAccess32(armNextPC
);
6148 // STRB Rd, [Rn, Rm, LSR #]!
6149 if (!busPrefetchCount
)
6150 busPrefetch
= busPrefetchEnable
;
6151 int shift
= (opcode
>> 7) & 31;
6152 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6153 int dest
= (opcode
>> 12) & 15;
6154 int base
= (opcode
>> 16) & 15;
6155 u32 address
= reg
[base
].I
+ offset
;
6156 reg
[base
].I
= address
;
6157 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6158 clockTicks
= 2 + dataTicksAccess16(address
) +
6159 codeTicksAccess32(armNextPC
);
6165 // STRB Rd, [Rn, Rm, ASR #]!
6166 if (!busPrefetchCount
)
6167 busPrefetch
= busPrefetchEnable
;
6168 int shift
= (opcode
>> 7) & 31;
6171 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6172 else if(reg
[opcode
& 15].I
& 0x80000000)
6173 offset
= 0xFFFFFFFF;
6176 int dest
= (opcode
>> 12) & 15;
6177 int base
= (opcode
>> 16) & 15;
6178 u32 address
= reg
[base
].I
+ offset
;
6179 reg
[base
].I
= address
;
6180 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6181 clockTicks
= 2 + dataTicksAccess16(address
) +
6182 codeTicksAccess32(armNextPC
);
6188 // STRB Rd, [Rn, Rm, ROR #]!
6189 if (!busPrefetchCount
)
6190 busPrefetch
= busPrefetchEnable
;
6191 int shift
= (opcode
>> 7) & 31;
6192 u32 value
= reg
[opcode
& 15].I
;
6198 int dest
= (opcode
>> 12) & 15;
6199 int base
= (opcode
>> 16) & 15;
6200 u32 address
= reg
[base
].I
+ value
;
6201 reg
[base
].I
= address
;
6202 CPUWriteByte(address
, reg
[dest
].B
.B0
);
6203 clockTicks
= 2 + dataTicksAccess16(address
) +
6204 codeTicksAccess32(armNextPC
);
6209 // T versions are the same
6213 // LDRB Rd, [Rn], -Rm, LSL #
6214 if (!busPrefetchCount
)
6215 busPrefetch
= busPrefetchEnable
;
6216 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6217 int dest
= (opcode
>> 12) & 15;
6218 int base
= (opcode
>> 16) & 15;
6219 u32 address
= reg
[base
].I
;
6220 reg
[dest
].I
= CPUReadByte(address
);
6222 reg
[base
].I
= address
- offset
;
6225 reg
[15].I
&= 0xFFFFFFFC;
6226 armNextPC
= reg
[15].I
;
6229 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6231 clockTicks
+= 3 + dataTicksAccess16(address
) +
6232 codeTicksAccess32(armNextPC
);
6237 // T versions are the same
6241 // LDRB Rd, [Rn], -Rm, LSR #
6242 if (!busPrefetchCount
)
6243 busPrefetch
= busPrefetchEnable
;
6244 int shift
= (opcode
>> 7) & 31;
6245 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6246 int dest
= (opcode
>> 12) & 15;
6247 int base
= (opcode
>> 16) & 15;
6248 u32 address
= reg
[base
].I
;
6249 reg
[dest
].I
= CPUReadByte(address
);
6251 reg
[base
].I
= address
- offset
;
6254 reg
[15].I
&= 0xFFFFFFFC;
6255 armNextPC
= reg
[15].I
;
6258 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6260 clockTicks
+= 3 + dataTicksAccess16(address
) +
6261 codeTicksAccess32(armNextPC
);
6266 // T versions are the same
6270 // LDRB Rd, [Rn], -Rm, ASR #
6271 if (!busPrefetchCount
)
6272 busPrefetch
= busPrefetchEnable
;
6273 int shift
= (opcode
>> 7) & 31;
6276 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6277 else if(reg
[opcode
& 15].I
& 0x80000000)
6278 offset
= 0xFFFFFFFF;
6281 int dest
= (opcode
>> 12) & 15;
6282 int base
= (opcode
>> 16) & 15;
6283 u32 address
= reg
[base
].I
;
6284 reg
[dest
].I
= CPUReadByte(address
);
6286 reg
[base
].I
= address
- offset
;
6289 reg
[15].I
&= 0xFFFFFFFC;
6290 armNextPC
= reg
[15].I
;
6293 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6295 clockTicks
+= 3 + dataTicksAccess16(address
) +
6296 codeTicksAccess32(armNextPC
);
6301 // T versions are the same
6305 // LDRB Rd, [Rn], -Rm, ROR #
6306 if (!busPrefetchCount
)
6307 busPrefetch
= busPrefetchEnable
;
6308 int shift
= (opcode
>> 7) & 31;
6309 u32 value
= reg
[opcode
& 15].I
;
6315 int dest
= (opcode
>> 12) & 15;
6316 int base
= (opcode
>> 16) & 15;
6317 u32 address
= reg
[base
].I
;
6318 reg
[dest
].I
= CPUReadByte(address
);
6320 reg
[base
].I
= address
- value
;
6323 reg
[15].I
&= 0xFFFFFFFC;
6324 armNextPC
= reg
[15].I
;
6327 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6329 clockTicks
+= 3 + dataTicksAccess16(address
) +
6330 codeTicksAccess32(armNextPC
);
6335 // T versions are the same
6339 // LDRB Rd, [Rn], Rm, LSL #
6340 if (!busPrefetchCount
)
6341 busPrefetch
= busPrefetchEnable
;
6342 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6343 int dest
= (opcode
>> 12) & 15;
6344 int base
= (opcode
>> 16) & 15;
6345 u32 address
= reg
[base
].I
;
6346 reg
[dest
].I
= CPUReadByte(address
);
6348 reg
[base
].I
= address
+ offset
;
6351 reg
[15].I
&= 0xFFFFFFFC;
6352 armNextPC
= reg
[15].I
;
6355 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6357 clockTicks
+= 3 + dataTicksAccess16(address
) +
6358 codeTicksAccess32(armNextPC
);
6363 // T versions are the same
6367 // LDRB Rd, [Rn], Rm, LSR #
6368 if (!busPrefetchCount
)
6369 busPrefetch
= busPrefetchEnable
;
6370 int shift
= (opcode
>> 7) & 31;
6371 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6372 int dest
= (opcode
>> 12) & 15;
6373 int base
= (opcode
>> 16) & 15;
6374 u32 address
= reg
[base
].I
;
6375 reg
[dest
].I
= CPUReadByte(address
);
6377 reg
[base
].I
= address
+ offset
;
6380 reg
[15].I
&= 0xFFFFFFFC;
6381 armNextPC
= reg
[15].I
;
6384 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6386 clockTicks
+= 3 + dataTicksAccess16(address
) +
6387 codeTicksAccess32(armNextPC
);
6392 // T versions are the same
6396 // LDRB Rd, [Rn], Rm, ASR #
6397 if (!busPrefetchCount
)
6398 busPrefetch
= busPrefetchEnable
;
6399 int shift
= (opcode
>> 7) & 31;
6402 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6403 else if(reg
[opcode
& 15].I
& 0x80000000)
6404 offset
= 0xFFFFFFFF;
6407 int dest
= (opcode
>> 12) & 15;
6408 int base
= (opcode
>> 16) & 15;
6409 u32 address
= reg
[base
].I
;
6410 reg
[dest
].I
= CPUReadByte(address
);
6412 reg
[base
].I
= address
+ offset
;
6415 reg
[15].I
&= 0xFFFFFFFC;
6416 armNextPC
= reg
[15].I
;
6419 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6421 clockTicks
+= 3 + dataTicksAccess16(address
) +
6422 codeTicksAccess32(armNextPC
);
6427 // T versions are the same
6431 // LDRB Rd, [Rn], Rm, ROR #
6432 if (!busPrefetchCount
)
6433 busPrefetch
= busPrefetchEnable
;
6434 int shift
= (opcode
>> 7) & 31;
6435 u32 value
= reg
[opcode
& 15].I
;
6441 int dest
= (opcode
>> 12) & 15;
6442 int base
= (opcode
>> 16) & 15;
6443 u32 address
= reg
[base
].I
;
6444 reg
[dest
].I
= CPUReadByte(address
);
6446 reg
[base
].I
= address
+ value
;
6449 reg
[15].I
&= 0xFFFFFFFC;
6450 armNextPC
= reg
[15].I
;
6453 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6455 clockTicks
+= 3 + dataTicksAccess16(address
) +
6456 codeTicksAccess32(armNextPC
);
6462 // LDRB Rd, [Rn, -Rm, LSL #]
6463 if (!busPrefetchCount
)
6464 busPrefetch
= busPrefetchEnable
;
6465 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6466 int dest
= (opcode
>> 12) & 15;
6467 int base
= (opcode
>> 16) & 15;
6468 u32 address
= reg
[base
].I
- offset
;
6469 reg
[dest
].I
= CPUReadByte(address
);
6472 reg
[15].I
&= 0xFFFFFFFC;
6473 armNextPC
= reg
[15].I
;
6476 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6478 clockTicks
+= 3 + dataTicksAccess16(address
) +
6479 codeTicksAccess32(armNextPC
);
6485 // LDRB Rd, [Rn, -Rm, LSR #]
6486 if (!busPrefetchCount
)
6487 busPrefetch
= busPrefetchEnable
;
6488 int shift
= (opcode
>> 7) & 31;
6489 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6490 int dest
= (opcode
>> 12) & 15;
6491 int base
= (opcode
>> 16) & 15;
6492 u32 address
= reg
[base
].I
- offset
;
6493 reg
[dest
].I
= CPUReadByte(address
);
6496 reg
[15].I
&= 0xFFFFFFFC;
6497 armNextPC
= reg
[15].I
;
6500 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6502 clockTicks
+= 3 + dataTicksAccess16(address
) +
6503 codeTicksAccess32(armNextPC
);
6509 // LDRB Rd, [Rn, -Rm, ASR #]
6510 if (!busPrefetchCount
)
6511 busPrefetch
= busPrefetchEnable
;
6512 int shift
= (opcode
>> 7) & 31;
6515 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6516 else if(reg
[opcode
& 15].I
& 0x80000000)
6517 offset
= 0xFFFFFFFF;
6520 int dest
= (opcode
>> 12) & 15;
6521 int base
= (opcode
>> 16) & 15;
6522 u32 address
= reg
[base
].I
- offset
;
6523 reg
[dest
].I
= CPUReadByte(address
);
6526 reg
[15].I
&= 0xFFFFFFFC;
6527 armNextPC
= reg
[15].I
;
6530 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6532 clockTicks
+= 3 + dataTicksAccess16(address
) +
6533 codeTicksAccess32(armNextPC
);
6539 // LDRB Rd, [Rn, -Rm, ROR #]
6540 if (!busPrefetchCount
)
6541 busPrefetch
= busPrefetchEnable
;
6542 int shift
= (opcode
>> 7) & 31;
6543 u32 value
= reg
[opcode
& 15].I
;
6549 int dest
= (opcode
>> 12) & 15;
6550 int base
= (opcode
>> 16) & 15;
6551 u32 address
= reg
[base
].I
- value
;
6552 reg
[dest
].I
= CPUReadByte(address
);
6555 reg
[15].I
&= 0xFFFFFFFC;
6556 armNextPC
= reg
[15].I
;
6559 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6561 clockTicks
+= 3 + dataTicksAccess16(address
) +
6562 codeTicksAccess32(armNextPC
);
6568 // LDRB Rd, [Rn, -Rm, LSL #]!
6569 if (!busPrefetchCount
)
6570 busPrefetch
= busPrefetchEnable
;
6571 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6572 int dest
= (opcode
>> 12) & 15;
6573 int base
= (opcode
>> 16) & 15;
6574 u32 address
= reg
[base
].I
- offset
;
6575 reg
[dest
].I
= CPUReadByte(address
);
6577 reg
[base
].I
= address
;
6580 reg
[15].I
&= 0xFFFFFFFC;
6581 armNextPC
= reg
[15].I
;
6584 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6586 clockTicks
+= 3 + dataTicksAccess16(address
) +
6587 codeTicksAccess32(armNextPC
);
6593 // LDRB Rd, [Rn, -Rm, LSR #]!
6594 if (!busPrefetchCount
)
6595 busPrefetch
= busPrefetchEnable
;
6596 int shift
= (opcode
>> 7) & 31;
6597 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6598 int dest
= (opcode
>> 12) & 15;
6599 int base
= (opcode
>> 16) & 15;
6600 u32 address
= reg
[base
].I
- offset
;
6601 reg
[dest
].I
= CPUReadByte(address
);
6603 reg
[base
].I
= address
;
6606 reg
[15].I
&= 0xFFFFFFFC;
6607 armNextPC
= reg
[15].I
;
6610 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6612 clockTicks
+= 3 + dataTicksAccess16(address
) +
6613 codeTicksAccess32(armNextPC
);
6619 // LDRB Rd, [Rn, -Rm, ASR #]!
6620 if (!busPrefetchCount
)
6621 busPrefetch
= busPrefetchEnable
;
6622 int shift
= (opcode
>> 7) & 31;
6625 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6626 else if(reg
[opcode
& 15].I
& 0x80000000)
6627 offset
= 0xFFFFFFFF;
6630 int dest
= (opcode
>> 12) & 15;
6631 int base
= (opcode
>> 16) & 15;
6632 u32 address
= reg
[base
].I
- offset
;
6633 reg
[dest
].I
= CPUReadByte(address
);
6635 reg
[base
].I
= address
;
6638 reg
[15].I
&= 0xFFFFFFFC;
6639 armNextPC
= reg
[15].I
;
6642 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6644 clockTicks
+= 3 + dataTicksAccess16(address
) +
6645 codeTicksAccess32(armNextPC
);
6651 // LDRB Rd, [Rn, -Rm, ROR #]!
6652 if (!busPrefetchCount
)
6653 busPrefetch
= busPrefetchEnable
;
6654 int shift
= (opcode
>> 7) & 31;
6655 u32 value
= reg
[opcode
& 15].I
;
6661 int dest
= (opcode
>> 12) & 15;
6662 int base
= (opcode
>> 16) & 15;
6663 u32 address
= reg
[base
].I
- value
;
6664 reg
[dest
].I
= CPUReadByte(address
);
6666 reg
[base
].I
= address
;
6669 reg
[15].I
&= 0xFFFFFFFC;
6670 armNextPC
= reg
[15].I
;
6673 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6675 clockTicks
+= 3 + dataTicksAccess16(address
) +
6676 codeTicksAccess32(armNextPC
);
6682 // LDRB Rd, [Rn, Rm, LSL #]
6683 if (!busPrefetchCount
)
6684 busPrefetch
= busPrefetchEnable
;
6685 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6686 int dest
= (opcode
>> 12) & 15;
6687 int base
= (opcode
>> 16) & 15;
6688 u32 address
= reg
[base
].I
+ offset
;
6689 reg
[dest
].I
= CPUReadByte(address
);
6692 reg
[15].I
&= 0xFFFFFFFC;
6693 armNextPC
= reg
[15].I
;
6696 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6698 clockTicks
+= 3 + dataTicksAccess16(address
) +
6699 codeTicksAccess32(armNextPC
);
6705 // LDRB Rd, [Rn, Rm, LSR #]
6706 if (!busPrefetchCount
)
6707 busPrefetch
= busPrefetchEnable
;
6708 int shift
= (opcode
>> 7) & 31;
6709 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6710 int dest
= (opcode
>> 12) & 15;
6711 int base
= (opcode
>> 16) & 15;
6712 u32 address
= reg
[base
].I
+ offset
;
6713 reg
[dest
].I
= CPUReadByte(address
);
6716 reg
[15].I
&= 0xFFFFFFFC;
6717 armNextPC
= reg
[15].I
;
6720 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6722 clockTicks
+= 3 + dataTicksAccess16(address
) +
6723 codeTicksAccess32(armNextPC
);
6729 // LDRB Rd, [Rn, Rm, ASR #]
6730 if (!busPrefetchCount
)
6731 busPrefetch
= busPrefetchEnable
;
6732 int shift
= (opcode
>> 7) & 31;
6735 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6736 else if(reg
[opcode
& 15].I
& 0x80000000)
6737 offset
= 0xFFFFFFFF;
6740 int dest
= (opcode
>> 12) & 15;
6741 int base
= (opcode
>> 16) & 15;
6742 u32 address
= reg
[base
].I
+ offset
;
6743 reg
[dest
].I
= CPUReadByte(address
);
6746 reg
[15].I
&= 0xFFFFFFFC;
6747 armNextPC
= reg
[15].I
;
6750 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6752 clockTicks
+= 3 + dataTicksAccess16(address
) +
6753 codeTicksAccess32(armNextPC
);
6759 // LDRB Rd, [Rn, Rm, ROR #]
6760 if (!busPrefetchCount
)
6761 busPrefetch
= busPrefetchEnable
;
6762 int shift
= (opcode
>> 7) & 31;
6763 u32 value
= reg
[opcode
& 15].I
;
6769 int dest
= (opcode
>> 12) & 15;
6770 int base
= (opcode
>> 16) & 15;
6771 u32 address
= reg
[base
].I
+ value
;
6772 reg
[dest
].I
= CPUReadByte(address
);
6775 reg
[15].I
&= 0xFFFFFFFC;
6776 armNextPC
= reg
[15].I
;
6779 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6781 clockTicks
+= 3 + dataTicksAccess16(address
) +
6782 codeTicksAccess32(armNextPC
);
6788 // LDRB Rd, [Rn, Rm, LSL #]!
6789 if (!busPrefetchCount
)
6790 busPrefetch
= busPrefetchEnable
;
6791 int offset
= reg
[opcode
& 15].I
<< ((opcode
>>7)& 31);
6792 int dest
= (opcode
>> 12) & 15;
6793 int base
= (opcode
>> 16) & 15;
6794 u32 address
= reg
[base
].I
+ offset
;
6795 reg
[dest
].I
= CPUReadByte(address
);
6797 reg
[base
].I
= address
;
6800 reg
[15].I
&= 0xFFFFFFFC;
6801 armNextPC
= reg
[15].I
;
6804 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6806 clockTicks
+= 3 + dataTicksAccess16(address
) +
6807 codeTicksAccess32(armNextPC
);
6813 // LDRB Rd, [Rn, Rm, LSR #]!
6814 if (!busPrefetchCount
)
6815 busPrefetch
= busPrefetchEnable
;
6816 int shift
= (opcode
>> 7) & 31;
6817 int offset
= shift
? reg
[opcode
& 15].I
>> shift
: 0;
6818 int dest
= (opcode
>> 12) & 15;
6819 int base
= (opcode
>> 16) & 15;
6820 u32 address
= reg
[base
].I
+ offset
;
6821 reg
[dest
].I
= CPUReadByte(address
);
6823 reg
[base
].I
= address
;
6826 reg
[15].I
&= 0xFFFFFFFC;
6827 armNextPC
= reg
[15].I
;
6830 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6832 clockTicks
+= 3 + dataTicksAccess16(address
) +
6833 codeTicksAccess32(armNextPC
);
6839 // LDRB Rd, [Rn, Rm, ASR #]!
6840 if (!busPrefetchCount
)
6841 busPrefetch
= busPrefetchEnable
;
6842 int shift
= (opcode
>> 7) & 31;
6845 offset
= (int)((s32
)reg
[opcode
& 15].I
>> shift
);
6846 else if(reg
[opcode
& 15].I
& 0x80000000)
6847 offset
= 0xFFFFFFFF;
6850 int dest
= (opcode
>> 12) & 15;
6851 int base
= (opcode
>> 16) & 15;
6852 u32 address
= reg
[base
].I
+ offset
;
6853 reg
[dest
].I
= CPUReadByte(address
);
6855 reg
[base
].I
= address
;
6858 reg
[15].I
&= 0xFFFFFFFC;
6859 armNextPC
= reg
[15].I
;
6862 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6864 clockTicks
+= 3 + dataTicksAccess16(address
) +
6865 codeTicksAccess32(armNextPC
);
6871 // LDRB Rd, [Rn, Rm, ROR #]!
6872 if (!busPrefetchCount
)
6873 busPrefetch
= busPrefetchEnable
;
6874 int shift
= (opcode
>> 7) & 31;
6875 u32 value
= reg
[opcode
& 15].I
;
6881 int dest
= (opcode
>> 12) & 15;
6882 int base
= (opcode
>> 16) & 15;
6883 u32 address
= reg
[base
].I
+ value
;
6884 reg
[dest
].I
= CPUReadByte(address
);
6886 reg
[base
].I
= address
;
6889 reg
[15].I
&= 0xFFFFFFFC;
6890 armNextPC
= reg
[15].I
;
6893 clockTicks
+= 2 + dataTicksAccessSeq32(address
) + dataTicksAccessSeq32(address
);
6895 clockTicks
+= 3 + dataTicksAccess16(address
) +
6896 codeTicksAccess32(armNextPC
);
6899 #define STMW_REG(val,num) \
6900 if(opcode & (val)) {\
6901 CPUWriteMemory(address, reg[(num)].I);\
6903 reg[base].I = temp;\
6904 clockTicks += 1 + dataTicksAccess32(address);\
6907 clockTicks += 1 + dataTicksAccessSeq32(address);\
6911 #define STM_REG(val,num) \
6912 if(opcode & (val)) {\
6913 CPUWriteMemory(address, reg[(num)].I);\
6915 clockTicks += 1 + dataTicksAccess32(address);\
6918 clockTicks += 1 + dataTicksAccessSeq32(address);\
6925 // STMDA Rn, {Rlist}
6926 if (!busPrefetchCount
)
6927 busPrefetch
= busPrefetchEnable
;
6928 int base
= (opcode
& 0x000F0000) >> 16;
6929 u32 temp
= reg
[base
].I
-
6930 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
6931 u32 address
= (temp
+ 4) & 0xFFFFFFFC;
6948 if(opcode
& 32768) {
6949 CPUWriteMemory(address
, reg
[15].I
+4);
6951 clockTicks
+= 1 + dataTicksAccess32(address
);
6953 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
6955 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
6960 // STMDA Rn!, {Rlist}
6961 if (!busPrefetchCount
)
6962 busPrefetch
= busPrefetchEnable
;
6963 int base
= (opcode
& 0x000F0000) >> 16;
6964 u32 temp
= reg
[base
].I
-
6965 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
6966 u32 address
= (temp
+4) & 0xFFFFFFFC;
6983 STMW_REG(16384, 14);
6984 if(opcode
& 32768) {
6985 CPUWriteMemory(address
, reg
[15].I
+4);
6987 clockTicks
+= 1 + dataTicksAccess32(address
);
6989 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
6992 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
6997 // STMDA Rn, {Rlist}^
6998 if (!busPrefetchCount
)
6999 busPrefetch
= busPrefetchEnable
;
7000 int base
= (opcode
& 0x000F0000) >> 16;
7001 u32 temp
= reg
[base
].I
-
7002 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7003 u32 address
= (temp
+4) & 0xFFFFFFFC;
7015 if(armMode
== 0x11) {
7016 STM_REG(256, R8_FIQ
);
7017 STM_REG(512, R9_FIQ
);
7018 STM_REG(1024, R10_FIQ
);
7019 STM_REG(2048, R11_FIQ
);
7020 STM_REG(4096, R12_FIQ
);
7029 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7030 STM_REG(8192, R13_USR
);
7031 STM_REG(16384, R14_USR
);
7037 if(opcode
& 32768) {
7038 CPUWriteMemory(address
, reg
[15].I
+4);
7040 clockTicks
+= 1 + dataTicksAccess32(address
);
7042 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7044 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7049 // STMDA Rn!, {Rlist}^
7050 if (!busPrefetchCount
)
7051 busPrefetch
= busPrefetchEnable
;
7052 int base
= (opcode
& 0x000F0000) >> 16;
7053 u32 temp
= reg
[base
].I
-
7054 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7055 u32 address
= (temp
+4) & 0xFFFFFFFC;
7067 if(armMode
== 0x11) {
7068 STMW_REG(256, R8_FIQ
);
7069 STMW_REG(512, R9_FIQ
);
7070 STMW_REG(1024, R10_FIQ
);
7071 STMW_REG(2048, R11_FIQ
);
7072 STMW_REG(4096, R12_FIQ
);
7081 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7082 STMW_REG(8192, R13_USR
);
7083 STMW_REG(16384, R14_USR
);
7086 STMW_REG(16384, 14);
7089 if(opcode
& 32768) {
7090 CPUWriteMemory(address
, reg
[15].I
+4);
7092 clockTicks
+= 1 + dataTicksAccess32(address
);
7094 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7097 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7103 // STMIA Rn, {Rlist}
7104 if (!busPrefetchCount
)
7105 busPrefetch
= busPrefetchEnable
;
7106 int base
= (opcode
& 0x000F0000) >> 16;
7107 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7124 if(opcode
& 32768) {
7125 CPUWriteMemory(address
, reg
[15].I
+4);
7127 clockTicks
+= 1 + dataTicksAccess32(address
);
7129 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7131 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7136 // STMIA Rn!, {Rlist}
7137 if (!busPrefetchCount
)
7138 busPrefetch
= busPrefetchEnable
;
7139 int base
= (opcode
& 0x000F0000) >> 16;
7140 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7142 u32 temp
= reg
[base
].I
+ 4*(cpuBitsSet
[opcode
& 0xFF] +
7143 cpuBitsSet
[(opcode
>> 8) & 255]);
7158 STMW_REG(16384, 14);
7159 if(opcode
& 32768) {
7160 CPUWriteMemory(address
, reg
[15].I
+4);
7163 clockTicks
+= 1 + dataTicksAccess32(address
);
7165 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7167 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7172 // STMIA Rn, {Rlist}^
7173 if (!busPrefetchCount
)
7174 busPrefetch
= busPrefetchEnable
;
7175 int base
= (opcode
& 0x000F0000) >> 16;
7176 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7186 if(armMode
== 0x11) {
7187 STM_REG(256, R8_FIQ
);
7188 STM_REG(512, R9_FIQ
);
7189 STM_REG(1024, R10_FIQ
);
7190 STM_REG(2048, R11_FIQ
);
7191 STM_REG(4096, R12_FIQ
);
7199 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7200 STM_REG(8192, R13_USR
);
7201 STM_REG(16384, R14_USR
);
7206 if(opcode
& 32768) {
7207 CPUWriteMemory(address
, reg
[15].I
+4);
7209 clockTicks
+= 1 + dataTicksAccess32(address
);
7211 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7213 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7218 // STMIA Rn!, {Rlist}^
7219 if (!busPrefetchCount
)
7220 busPrefetch
= busPrefetchEnable
;
7221 int base
= (opcode
& 0x000F0000) >> 16;
7222 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7224 u32 temp
= reg
[base
].I
+ 4*(cpuBitsSet
[opcode
& 0xFF] +
7225 cpuBitsSet
[(opcode
>> 8) & 255]);
7234 if(armMode
== 0x11) {
7235 STMW_REG(256, R8_FIQ
);
7236 STMW_REG(512, R9_FIQ
);
7237 STMW_REG(1024, R10_FIQ
);
7238 STMW_REG(2048, R11_FIQ
);
7239 STMW_REG(4096, R12_FIQ
);
7247 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7248 STMW_REG(8192, R13_USR
);
7249 STMW_REG(16384, R14_USR
);
7252 STMW_REG(16384, 14);
7254 if(opcode
& 32768) {
7255 CPUWriteMemory(address
, reg
[15].I
+4);
7258 clockTicks
+= 1 + dataTicksAccess32(address
);
7260 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7262 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7268 // STMDB Rn, {Rlist}
7269 if (!busPrefetchCount
)
7270 busPrefetch
= busPrefetchEnable
;
7271 int base
= (opcode
& 0x000F0000) >> 16;
7272 u32 temp
= reg
[base
].I
-
7273 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7274 u32 address
= temp
& 0xFFFFFFFC;
7291 if(opcode
& 32768) {
7292 CPUWriteMemory(address
, reg
[15].I
+4);
7294 clockTicks
+= 1 + dataTicksAccess32(address
);
7296 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7298 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7303 // STMDB Rn!, {Rlist}
7304 if (!busPrefetchCount
)
7305 busPrefetch
= busPrefetchEnable
;
7306 int base
= (opcode
& 0x000F0000) >> 16;
7307 u32 temp
= reg
[base
].I
-
7308 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7309 u32 address
= temp
& 0xFFFFFFFC;
7326 STMW_REG(16384, 14);
7327 if(opcode
& 32768) {
7328 CPUWriteMemory(address
, reg
[15].I
+4);
7330 clockTicks
+= 1 + dataTicksAccess32(address
);
7332 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7335 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7340 // STMDB Rn, {Rlist}^
7341 if (!busPrefetchCount
)
7342 busPrefetch
= busPrefetchEnable
;
7343 int base
= (opcode
& 0x000F0000) >> 16;
7344 u32 temp
= reg
[base
].I
-
7345 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7346 u32 address
= temp
& 0xFFFFFFFC;
7358 if(armMode
== 0x11) {
7359 STM_REG(256, R8_FIQ
);
7360 STM_REG(512, R9_FIQ
);
7361 STM_REG(1024, R10_FIQ
);
7362 STM_REG(2048, R11_FIQ
);
7363 STM_REG(4096, R12_FIQ
);
7372 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7373 STM_REG(8192, R13_USR
);
7374 STM_REG(16384, R14_USR
);
7380 if(opcode
& 32768) {
7381 CPUWriteMemory(address
, reg
[15].I
+4);
7383 clockTicks
+= 1 + dataTicksAccess32(address
);
7385 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7387 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7392 // STMDB Rn!, {Rlist}^
7393 if (!busPrefetchCount
)
7394 busPrefetch
= busPrefetchEnable
;
7395 int base
= (opcode
& 0x000F0000) >> 16;
7396 u32 temp
= reg
[base
].I
-
7397 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7398 u32 address
= temp
& 0xFFFFFFFC;
7410 if(armMode
== 0x11) {
7411 STMW_REG(256, R8_FIQ
);
7412 STMW_REG(512, R9_FIQ
);
7413 STMW_REG(1024, R10_FIQ
);
7414 STMW_REG(2048, R11_FIQ
);
7415 STMW_REG(4096, R12_FIQ
);
7424 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7425 STMW_REG(8192, R13_USR
);
7426 STMW_REG(16384, R14_USR
);
7429 STMW_REG(16384, 14);
7432 if(opcode
& 32768) {
7433 CPUWriteMemory(address
, reg
[15].I
+4);
7435 clockTicks
+= 1 + dataTicksAccess32(address
);
7437 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7440 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7446 // STMIB Rn, {Rlist}
7447 if (!busPrefetchCount
)
7448 busPrefetch
= busPrefetchEnable
;
7449 int base
= (opcode
& 0x000F0000) >> 16;
7450 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
7467 if(opcode
& 32768) {
7468 CPUWriteMemory(address
, reg
[15].I
+4);
7470 clockTicks
+= 1 + dataTicksAccess32(address
);
7472 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7474 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7479 // STMIB Rn!, {Rlist}
7480 if (!busPrefetchCount
)
7481 busPrefetch
= busPrefetchEnable
;
7482 int base
= (opcode
& 0x000F0000) >> 16;
7483 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
7485 u32 temp
= reg
[base
].I
+ 4*(cpuBitsSet
[opcode
& 0xFF] +
7486 cpuBitsSet
[(opcode
>> 8) & 255]);
7501 STMW_REG(16384, 14);
7502 if(opcode
& 32768) {
7503 CPUWriteMemory(address
, reg
[15].I
+4);
7506 clockTicks
+= 1 + dataTicksAccess32(address
);
7508 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7510 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7515 // STMIB Rn, {Rlist}^
7516 if (!busPrefetchCount
)
7517 busPrefetch
= busPrefetchEnable
;
7518 int base
= (opcode
& 0x000F0000) >> 16;
7519 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
7529 if(armMode
== 0x11) {
7530 STM_REG(256, R8_FIQ
);
7531 STM_REG(512, R9_FIQ
);
7532 STM_REG(1024, R10_FIQ
);
7533 STM_REG(2048, R11_FIQ
);
7534 STM_REG(4096, R12_FIQ
);
7542 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7543 STM_REG(8192, R13_USR
);
7544 STM_REG(16384, R14_USR
);
7549 if(opcode
& 32768) {
7550 CPUWriteMemory(address
, reg
[15].I
+4);
7552 clockTicks
+= 1 + dataTicksAccess32(address
);
7554 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7556 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7561 // STMIB Rn!, {Rlist}^
7562 if (!busPrefetchCount
)
7563 busPrefetch
= busPrefetchEnable
;
7564 int base
= (opcode
& 0x000F0000) >> 16;
7565 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
7567 u32 temp
= reg
[base
].I
+ 4*(cpuBitsSet
[opcode
& 0xFF] +
7568 cpuBitsSet
[(opcode
>> 8) & 255]);
7577 if(armMode
== 0x11) {
7578 STMW_REG(256, R8_FIQ
);
7579 STMW_REG(512, R9_FIQ
);
7580 STMW_REG(1024, R10_FIQ
);
7581 STMW_REG(2048, R11_FIQ
);
7582 STMW_REG(4096, R12_FIQ
);
7590 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7591 STMW_REG(8192, R13_USR
);
7592 STMW_REG(16384, R14_USR
);
7595 STMW_REG(16384, 14);
7597 if(opcode
& 32768) {
7598 CPUWriteMemory(address
, reg
[15].I
+4);
7601 clockTicks
+= 1 + dataTicksAccess32(address
);
7603 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7605 clockTicks
+= 1 + codeTicksAccess32(armNextPC
);
7609 #define LDM_REG(val,num) \
7610 if(opcode & (val)) {\
7611 reg[(num)].I = CPUReadMemory(address);\
7613 clockTicks += 1 + dataTicksAccessSeq32(address);\
7615 clockTicks += 1 + dataTicksAccess32(address);\
7623 // LDMDA Rn, {Rlist}
7624 if (!busPrefetchCount
)
7625 busPrefetch
= busPrefetchEnable
;
7626 int base
= (opcode
& 0x000F0000) >> 16;
7627 u32 temp
= reg
[base
].I
-
7628 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7629 u32 address
= (temp
+ 4) & 0xFFFFFFFC;
7647 if(opcode
& 32768) {
7648 reg
[15].I
= CPUReadMemory(address
);
7649 armNextPC
= reg
[15].I
;
7653 clockTicks
+= 1 + dataTicksAccess32(address
);
7655 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7656 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7658 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7663 // LDMDA Rn!, {Rlist}
7664 if (!busPrefetchCount
)
7665 busPrefetch
= busPrefetchEnable
;
7666 int base
= (opcode
& 0x000F0000) >> 16;
7667 u32 temp
= reg
[base
].I
-
7668 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7669 u32 address
= (temp
+ 4) & 0xFFFFFFFC;
7687 if(opcode
& 32768) {
7688 reg
[15].I
= CPUReadMemory(address
);
7690 armNextPC
= reg
[15].I
;
7694 clockTicks
+= 1 + dataTicksAccess32(address
);
7696 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7697 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7699 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7700 if(!(opcode
& (1 << base
)))
7706 // LDMDA Rn, {Rlist}^
7707 if (!busPrefetchCount
)
7708 busPrefetch
= busPrefetchEnable
;
7709 int base
= (opcode
& 0x000F0000) >> 16;
7710 u32 temp
= reg
[base
].I
-
7711 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7712 u32 address
= (temp
+ 4) & 0xFFFFFFFC;
7715 if(opcode
& 0x8000) {
7732 reg
[15].I
= CPUReadMemory(address
);
7734 CPUSwitchMode(reg
[17].I
& 0x1f, false);
7736 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
7737 reg
[15].I
= armNextPC
+ 4;
7740 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
7741 reg
[15].I
= armNextPC
+ 2;
7754 if(armMode
== 0x11) {
7755 LDM_REG(256, R8_FIQ
);
7756 LDM_REG(512, R9_FIQ
);
7757 LDM_REG(1024, R10_FIQ
);
7758 LDM_REG(2048, R11_FIQ
);
7759 LDM_REG(4096, R12_FIQ
);
7768 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7769 LDM_REG(8192, R13_USR
);
7770 LDM_REG(16384, R14_USR
);
7776 clockTicks
+= 1 + dataTicksAccess32(address
);
7778 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7779 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7781 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7786 // LDMDA Rn!, {Rlist}^
7787 if (!busPrefetchCount
)
7788 busPrefetch
= busPrefetchEnable
;
7789 int base
= (opcode
& 0x000F0000) >> 16;
7790 u32 temp
= reg
[base
].I
-
7791 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7792 u32 address
= (temp
+ 4) & 0xFFFFFFFC;
7795 if(opcode
& 0x8000) {
7812 reg
[15].I
= CPUReadMemory(address
);
7814 if(!(opcode
& (1 << base
)))
7817 CPUSwitchMode(reg
[17].I
& 0x1f, false);
7819 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
7820 reg
[15].I
= armNextPC
+ 4;
7823 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
7824 reg
[15].I
= armNextPC
+ 2;
7837 if(armMode
== 0x11) {
7838 LDM_REG(256, R8_FIQ
);
7839 LDM_REG(512, R9_FIQ
);
7840 LDM_REG(1024, R10_FIQ
);
7841 LDM_REG(2048, R11_FIQ
);
7842 LDM_REG(4096, R12_FIQ
);
7851 if(armMode
!= 0x10 && armMode
!= 0x1f) {
7852 LDM_REG(8192, R13_USR
);
7853 LDM_REG(16384, R14_USR
);
7859 if(!(opcode
& (1 << base
)))
7862 clockTicks
+= 1 + dataTicksAccess32(address
);
7864 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7865 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7867 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7873 // LDMIA Rn, {Rlist}
7874 if (!busPrefetchCount
)
7875 busPrefetch
= busPrefetchEnable
;
7876 int base
= (opcode
& 0x000F0000) >> 16;
7877 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7895 if(opcode
& 32768) {
7896 reg
[15].I
= CPUReadMemory(address
);
7898 armNextPC
= reg
[15].I
;
7902 clockTicks
+= 1 + dataTicksAccess32(address
);
7904 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7905 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7907 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7912 // LDMIA Rn!, {Rlist}
7913 if (!busPrefetchCount
)
7914 busPrefetch
= busPrefetchEnable
;
7915 int base
= (opcode
& 0x000F0000) >> 16;
7916 u32 temp
= reg
[base
].I
+
7917 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
7918 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7936 if(opcode
& 32768) {
7937 reg
[15].I
= CPUReadMemory(address
);
7939 armNextPC
= reg
[15].I
;
7943 clockTicks
+= 1 + dataTicksAccess32(address
);
7945 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
7946 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
7948 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
7949 if(!(opcode
& (1 << base
)))
7955 // LDMIA Rn, {Rlist}^
7956 if (!busPrefetchCount
)
7957 busPrefetch
= busPrefetchEnable
;
7958 int base
= (opcode
& 0x000F0000) >> 16;
7959 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
7962 if(opcode
& 0x8000) {
7979 reg
[15].I
= CPUReadMemory(address
);
7981 CPUSwitchMode(reg
[17].I
& 0x1f, false);
7983 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
7984 reg
[15].I
= armNextPC
+ 4;
7987 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
7988 reg
[15].I
= armNextPC
+ 2;
8001 if(armMode
== 0x11) {
8002 LDM_REG(256, R8_FIQ
);
8003 LDM_REG(512, R9_FIQ
);
8004 LDM_REG(1024, R10_FIQ
);
8005 LDM_REG(2048, R11_FIQ
);
8006 LDM_REG(4096, R12_FIQ
);
8015 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8016 LDM_REG(8192, R13_USR
);
8017 LDM_REG(16384, R14_USR
);
8023 clockTicks
+= 1 + dataTicksAccess32(address
);
8025 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8026 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8028 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8033 // LDMIA Rn!, {Rlist}^
8034 if (!busPrefetchCount
)
8035 busPrefetch
= busPrefetchEnable
;
8036 int base
= (opcode
& 0x000F0000) >> 16;
8037 u32 temp
= reg
[base
].I
+
8038 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8039 u32 address
= reg
[base
].I
& 0xFFFFFFFC;
8042 if(opcode
& 0x8000) {
8059 reg
[15].I
= CPUReadMemory(address
);
8061 if(!(opcode
& (1 << base
)))
8064 CPUSwitchMode(reg
[17].I
& 0x1f, false);
8066 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
8067 reg
[15].I
= armNextPC
+ 4;
8070 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
8071 reg
[15].I
= armNextPC
+ 2;
8084 if(armMode
== 0x11) {
8085 LDM_REG(256, R8_FIQ
);
8086 LDM_REG(512, R9_FIQ
);
8087 LDM_REG(1024, R10_FIQ
);
8088 LDM_REG(2048, R11_FIQ
);
8089 LDM_REG(4096, R12_FIQ
);
8098 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8099 LDM_REG(8192, R13_USR
);
8100 LDM_REG(16384, R14_USR
);
8106 if(!(opcode
& (1 << base
)))
8109 clockTicks
+= 1 + dataTicksAccess32(address
);
8111 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8112 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8114 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8120 // LDMDB Rn, {Rlist}
8121 if (!busPrefetchCount
)
8122 busPrefetch
= busPrefetchEnable
;
8123 int base
= (opcode
& 0x000F0000) >> 16;
8124 u32 temp
= reg
[base
].I
-
8125 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8126 u32 address
= temp
& 0xFFFFFFFC;
8144 if(opcode
& 32768) {
8145 reg
[15].I
= CPUReadMemory(address
);
8147 armNextPC
= reg
[15].I
;
8151 clockTicks
+= 1 + dataTicksAccess32(address
);
8153 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8154 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8156 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8161 // LDMDB Rn!, {Rlist}
8162 if (!busPrefetchCount
)
8163 busPrefetch
= busPrefetchEnable
;
8164 int base
= (opcode
& 0x000F0000) >> 16;
8165 u32 temp
= reg
[base
].I
-
8166 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8167 u32 address
= temp
& 0xFFFFFFFC;
8185 if(opcode
& 32768) {
8186 reg
[15].I
= CPUReadMemory(address
);
8188 armNextPC
= reg
[15].I
;
8192 clockTicks
+= 1 + dataTicksAccess32(address
);
8194 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8195 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8197 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8198 if(!(opcode
& (1 << base
)))
8204 // LDMDB Rn, {Rlist}^
8205 if (!busPrefetchCount
)
8206 busPrefetch
= busPrefetchEnable
;
8207 int base
= (opcode
& 0x000F0000) >> 16;
8208 u32 temp
= reg
[base
].I
-
8209 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8210 u32 address
= temp
& 0xFFFFFFFC;
8213 if(opcode
& 0x8000) {
8230 reg
[15].I
= CPUReadMemory(address
);
8232 CPUSwitchMode(reg
[17].I
& 0x1f, false);
8234 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
8235 reg
[15].I
= armNextPC
+ 4;
8238 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
8239 reg
[15].I
= armNextPC
+ 2;
8252 if(armMode
== 0x11) {
8253 LDM_REG(256, R8_FIQ
);
8254 LDM_REG(512, R9_FIQ
);
8255 LDM_REG(1024, R10_FIQ
);
8256 LDM_REG(2048, R11_FIQ
);
8257 LDM_REG(4096, R12_FIQ
);
8266 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8267 LDM_REG(8192, R13_USR
);
8268 LDM_REG(16384, R14_USR
);
8274 clockTicks
+= 1 + dataTicksAccess32(address
);
8276 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8277 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8279 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8284 // LDMDB Rn!, {Rlist}^
8285 if (!busPrefetchCount
)
8286 busPrefetch
= busPrefetchEnable
;
8287 int base
= (opcode
& 0x000F0000) >> 16;
8288 u32 temp
= reg
[base
].I
-
8289 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8290 u32 address
= temp
& 0xFFFFFFFC;
8293 if(opcode
& 0x8000) {
8310 reg
[15].I
= CPUReadMemory(address
);
8312 if(!(opcode
& (1 << base
)))
8315 CPUSwitchMode(reg
[17].I
& 0x1f, false);
8317 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
8318 reg
[15].I
= armNextPC
+ 4;
8321 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
8322 reg
[15].I
= armNextPC
+ 2;
8335 if(armMode
== 0x11) {
8336 LDM_REG(256, R8_FIQ
);
8337 LDM_REG(512, R9_FIQ
);
8338 LDM_REG(1024, R10_FIQ
);
8339 LDM_REG(2048, R11_FIQ
);
8340 LDM_REG(4096, R12_FIQ
);
8349 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8350 LDM_REG(8192, R13_USR
);
8351 LDM_REG(16384, R14_USR
);
8357 if(!(opcode
& (1 << base
)))
8360 clockTicks
+= 1 + dataTicksAccess32(address
);
8362 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8363 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8365 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8371 // LDMIB Rn, {Rlist}
8372 if (!busPrefetchCount
)
8373 busPrefetch
= busPrefetchEnable
;
8374 int base
= (opcode
& 0x000F0000) >> 16;
8375 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
8393 if(opcode
& 32768) {
8394 reg
[15].I
= CPUReadMemory(address
);
8396 armNextPC
= reg
[15].I
;
8400 clockTicks
+= 1 + dataTicksAccess32(address
);
8402 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8403 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8405 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8410 // LDMIB Rn!, {Rlist}
8411 if (!busPrefetchCount
)
8412 busPrefetch
= busPrefetchEnable
;
8413 int base
= (opcode
& 0x000F0000) >> 16;
8414 u32 temp
= reg
[base
].I
+
8415 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8416 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
8434 if(opcode
& 32768) {
8435 reg
[15].I
= CPUReadMemory(address
);
8437 clockTicks
+= 1 + dataTicksAccess32(address
);
8439 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8440 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8442 armNextPC
= reg
[15].I
;
8446 clockTicks
+= 1 + dataTicksAccess32(address
);
8448 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8449 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8451 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8452 if(!(opcode
& (1 << base
)))
8458 // LDMIB Rn, {Rlist}^
8459 if (!busPrefetchCount
)
8460 busPrefetch
= busPrefetchEnable
;
8461 int base
= (opcode
& 0x000F0000) >> 16;
8462 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
8465 if(opcode
& 0x8000) {
8482 reg
[15].I
= CPUReadMemory(address
);
8484 CPUSwitchMode(reg
[17].I
& 0x1f, false);
8486 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
8487 reg
[15].I
= armNextPC
+ 4;
8490 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
8491 reg
[15].I
= armNextPC
+ 2;
8504 if(armMode
== 0x11) {
8505 LDM_REG(256, R8_FIQ
);
8506 LDM_REG(512, R9_FIQ
);
8507 LDM_REG(1024, R10_FIQ
);
8508 LDM_REG(2048, R11_FIQ
);
8509 LDM_REG(4096, R12_FIQ
);
8518 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8519 LDM_REG(8192, R13_USR
);
8520 LDM_REG(16384, R14_USR
);
8526 clockTicks
+= 1 + dataTicksAccess32(address
);
8528 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8529 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8531 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8536 // LDMIB Rn!, {Rlist}^
8537 if (!busPrefetchCount
)
8538 busPrefetch
= busPrefetchEnable
;
8539 int base
= (opcode
& 0x000F0000) >> 16;
8540 u32 temp
= reg
[base
].I
+
8541 4 * (cpuBitsSet
[opcode
& 255] + cpuBitsSet
[(opcode
>> 8) & 255]);
8542 u32 address
= (reg
[base
].I
+4) & 0xFFFFFFFC;
8545 if(opcode
& 0x8000) {
8562 reg
[15].I
= CPUReadMemory(address
);
8564 if(!(opcode
& (1 << base
)))
8567 CPUSwitchMode(reg
[17].I
& 0x1f, false);
8569 armNextPC
= reg
[15].I
& 0xFFFFFFFC;
8570 reg
[15].I
= armNextPC
+ 4;
8573 armNextPC
= reg
[15].I
& 0xFFFFFFFE;
8574 reg
[15].I
= armNextPC
+ 2;
8587 if(armMode
== 0x11) {
8588 LDM_REG(256, R8_FIQ
);
8589 LDM_REG(512, R9_FIQ
);
8590 LDM_REG(1024, R10_FIQ
);
8591 LDM_REG(2048, R11_FIQ
);
8592 LDM_REG(4096, R12_FIQ
);
8601 if(armMode
!= 0x10 && armMode
!= 0x1f) {
8602 LDM_REG(8192, R13_USR
);
8603 LDM_REG(16384, R14_USR
);
8609 if(!(opcode
& (1 << base
)))
8612 clockTicks
+= 1 + dataTicksAccess32(address
);
8614 clockTicks
+= 1 + dataTicksAccessSeq32(address
);
8615 clockTicks
+= 1 + codeTicksAccessSeq32(armNextPC
);
8617 clockTicks
+= 2 + codeTicksAccess32(armNextPC
);
8623 int offset
= opcode
& 0x00FFFFFF;
8624 if(offset
& 0x00800000) {
8625 offset
|= 0xFF000000;
8628 reg
[15].I
+= offset
;
8629 armNextPC
= reg
[15].I
;
8632 clockTicks
= codeTicksAccessSeq32(armNextPC
) + 1;
8633 clockTicks
+= 2 + codeTicksAccess32(armNextPC
) +
8634 codeTicksAccessSeq32(armNextPC
);
8641 int offset
= opcode
& 0x00FFFFFF;
8642 if(offset
& 0x00800000) {
8643 offset
|= 0xFF000000;
8646 reg
[14].I
= reg
[15].I
- 4;
8647 reg
[15].I
+= offset
;
8648 armNextPC
= reg
[15].I
;
8651 clockTicks
= codeTicksAccessSeq32(armNextPC
) + 1;
8652 clockTicks
+= 2 + codeTicksAccess32(armNextPC
) +
8653 codeTicksAccessSeq32(armNextPC
);
8659 clockTicks
= codeTicksAccessSeq32(armNextPC
) + 1;
8660 clockTicks
+= 2 + codeTicksAccess32(armNextPC
) +
8661 codeTicksAccessSeq32(armNextPC
);
8663 CPUSoftwareInterrupt(opcode
& 0x00FFFFFF);
8690 if(systemVerbose
& VERBOSE_UNDEFINED
)
8691 log("Undefined ARM instruction %08x at %08x\n", opcode
,
8694 CPUUndefinedException();
8700 if (clockTicks
== 0)
8701 clockTicks
= codeTicksAccessSeq32(oldArmNextPC
) + 1;