26 |
|
|
27 |
|
#if defined(SPARC_V8_ASSEMBLY) || defined(SPARC_V9_ASSEMBLY) |
28 |
|
#define SPARC_ASSEMBLY 0 |
29 |
– |
#include "sparcasm.h" |
29 |
|
#endif |
30 |
|
|
31 |
|
#define BOOL_TYPE "int" |
59 |
|
if (file) { |
60 |
|
fscanf (file, "Total: %lu\n", &total); |
61 |
|
while (fscanf (file, "%lx: %lu %s\n", &opcode, &count, name) == 3) { |
62 |
< |
opcode_next_clev[nr] = 3; |
62 |
> |
opcode_next_clev[nr] = 4; |
63 |
|
opcode_last_postfix[nr] = -1; |
64 |
|
opcode_map[nr++] = opcode; |
65 |
|
counts[opcode] = count; |
72 |
|
if (table68k[opcode].handler == -1 && table68k[opcode].mnemo != i_ILLG |
73 |
|
&& counts[opcode] == 0) |
74 |
|
{ |
75 |
< |
opcode_next_clev[nr] = 3; |
75 |
> |
opcode_next_clev[nr] = 4; |
76 |
|
opcode_last_postfix[nr] = -1; |
77 |
|
opcode_map[nr++] = opcode; |
78 |
|
counts[opcode] = count; |
221 |
|
} |
222 |
|
|
223 |
|
/* getv == 1: fetch data; getv != 0: check for odd address. If movem != 0, |
224 |
< |
* the calling routine handles Apdi and Aipi modes. */ |
224 |
> |
* the calling routine handles Apdi and Aipi modes. |
225 |
> |
* gb-- movem == 2 means the same thing but for a MOVE16 instruction */ |
226 |
|
static void genamode (amodes mode, char *reg, wordsizes size, char *name, int getv, int movem) |
227 |
|
{ |
228 |
|
start_brace (); |
233 |
|
if (getv == 1) |
234 |
|
switch (size) { |
235 |
|
case sz_byte: |
236 |
< |
#ifdef AMIGA |
236 |
> |
#if defined(AMIGA) && !defined(WARPUP) |
237 |
|
/* sam: I don't know why gcc.2.7.2.1 produces a code worse */ |
238 |
|
/* if it is not done like that: */ |
239 |
|
printf ("\tuae_s8 %s = ((uae_u8*)&m68k_dreg(regs, %s))[3];\n", name, reg); |
242 |
|
#endif |
243 |
|
break; |
244 |
|
case sz_word: |
245 |
< |
#ifdef AMIGA |
245 |
> |
#if defined(AMIGA) && !defined(WARPUP) |
246 |
|
printf ("\tuae_s16 %s = ((uae_s16*)&m68k_dreg(regs, %s))[1];\n", name, reg); |
247 |
|
#else |
248 |
|
printf ("\tuae_s16 %s = m68k_dreg(regs, %s);\n", name, reg); |
715 |
|
|
716 |
|
static void genflags (flagtypes type, wordsizes size, char *value, char *src, char *dst) |
717 |
|
{ |
718 |
< |
#ifdef SPARC_V8_ASSEMBLY |
719 |
< |
switch(type) |
720 |
< |
{ |
721 |
< |
case flag_add: |
722 |
< |
start_brace(); |
723 |
< |
printf("\tuae_u32 %s;\n", value); |
724 |
< |
switch(size) |
725 |
< |
{ |
726 |
< |
case sz_byte: |
727 |
< |
printf("\t%s = sparc_v8_flag_add_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
728 |
< |
break; |
729 |
< |
case sz_word: |
730 |
< |
printf("\t%s = sparc_v8_flag_add_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
731 |
< |
break; |
732 |
< |
case sz_long: |
733 |
< |
printf("\t%s = sparc_v8_flag_add_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
734 |
< |
break; |
735 |
< |
} |
736 |
< |
return; |
737 |
< |
|
738 |
< |
case flag_sub: |
739 |
< |
start_brace(); |
740 |
< |
printf("\tuae_u32 %s;\n", value); |
741 |
< |
switch(size) |
742 |
< |
{ |
743 |
< |
case sz_byte: |
744 |
< |
printf("\t%s = sparc_v8_flag_sub_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
745 |
< |
break; |
746 |
< |
case sz_word: |
747 |
< |
printf("\t%s = sparc_v8_flag_sub_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
748 |
< |
break; |
749 |
< |
case sz_long: |
750 |
< |
printf("\t%s = sparc_v8_flag_sub_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
751 |
< |
break; |
752 |
< |
} |
753 |
< |
return; |
754 |
< |
|
755 |
< |
case flag_cmp: |
756 |
< |
switch(size) |
757 |
< |
{ |
758 |
< |
case sz_byte: |
759 |
< |
// printf("\tsparc_v8_flag_cmp_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
760 |
< |
break; |
761 |
< |
case sz_word: |
762 |
< |
// printf("\tsparc_v8_flag_cmp_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
763 |
< |
break; |
764 |
< |
case sz_long: |
765 |
< |
#if 1 |
766 |
< |
printf("\tsparc_v8_flag_cmp_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
767 |
< |
return; |
768 |
< |
#endif |
769 |
< |
break; |
770 |
< |
} |
771 |
< |
// return; |
772 |
< |
break; |
773 |
< |
} |
774 |
< |
#elif defined(SPARC_V9_ASSEMBLY) |
775 |
< |
switch(type) |
776 |
< |
{ |
777 |
< |
case flag_add: |
778 |
< |
start_brace(); |
779 |
< |
printf("\tuae_u32 %s;\n", value); |
780 |
< |
switch(size) |
781 |
< |
{ |
782 |
< |
case sz_byte: |
783 |
< |
printf("\t%s = sparc_v9_flag_add_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
784 |
< |
break; |
785 |
< |
case sz_word: |
786 |
< |
printf("\t%s = sparc_v9_flag_add_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
787 |
< |
break; |
788 |
< |
case sz_long: |
789 |
< |
printf("\t%s = sparc_v9_flag_add_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
790 |
< |
break; |
791 |
< |
} |
792 |
< |
return; |
793 |
< |
|
794 |
< |
case flag_sub: |
795 |
< |
start_brace(); |
796 |
< |
printf("\tuae_u32 %s;\n", value); |
797 |
< |
switch(size) |
798 |
< |
{ |
799 |
< |
case sz_byte: |
800 |
< |
printf("\t%s = sparc_v9_flag_sub_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
801 |
< |
break; |
802 |
< |
case sz_word: |
803 |
< |
printf("\t%s = sparc_v9_flag_sub_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
804 |
< |
break; |
805 |
< |
case sz_long: |
806 |
< |
printf("\t%s = sparc_v9_flag_sub_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
807 |
< |
break; |
808 |
< |
} |
809 |
< |
return; |
810 |
< |
|
811 |
< |
case flag_cmp: |
812 |
< |
switch(size) |
813 |
< |
{ |
814 |
< |
case sz_byte: |
815 |
< |
printf("\tsparc_v9_flag_cmp_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
816 |
< |
break; |
817 |
< |
case sz_word: |
818 |
< |
printf("\tsparc_v9_flag_cmp_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
819 |
< |
break; |
820 |
< |
case sz_long: |
821 |
< |
printf("\tsparc_v9_flag_cmp_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
822 |
< |
break; |
823 |
< |
} |
824 |
< |
return; |
825 |
< |
|
826 |
< |
case flag_logical: |
827 |
< |
if (strcmp(value, "0") == 0) { |
828 |
< |
printf("\tregflags.nzvc = 0x04;\n"); |
829 |
< |
} else { |
830 |
< |
switch(size) { |
831 |
< |
case sz_byte: |
832 |
< |
printf("\tsparc_v9_flag_test_8(®flags, (uae_u32)(%s));\n", value); |
833 |
< |
break; |
834 |
< |
case sz_word: |
835 |
< |
printf("\tsparc_v9_flag_test_16(®flags, (uae_u32)(%s));\n", value); |
836 |
< |
break; |
837 |
< |
case sz_long: |
838 |
< |
printf("\tsparc_v9_flag_test_32(®flags, (uae_u32)(%s));\n", value); |
839 |
< |
break; |
840 |
< |
} |
841 |
< |
} |
842 |
< |
return; |
843 |
< |
|
844 |
< |
#if 0 |
845 |
< |
case flag_logical_noclobber: |
846 |
< |
printf("\t{uae_u32 old_flags = regflags.nzvc & ~0x0C;\n"); |
847 |
< |
if (strcmp(value, "0") == 0) { |
848 |
< |
printf("\tregflags.nzvc = old_flags | 0x04;\n"); |
849 |
< |
} else { |
850 |
< |
switch(size) { |
851 |
< |
case sz_byte: |
852 |
< |
printf("\tsparc_v9_flag_test_8(®flags, (uae_u32)(%s));\n", value); |
853 |
< |
break; |
854 |
< |
case sz_word: |
855 |
< |
printf("\tsparc_v9_flag_test_16(®flags, (uae_u32)(%s));\n", value); |
856 |
< |
break; |
857 |
< |
case sz_long: |
858 |
< |
printf("\tsparc_v9_flag_test_32(®flags, (uae_u32)(%s));\n", value); |
859 |
< |
break; |
860 |
< |
} |
861 |
< |
printf("\tregflags.nzvc |= old_flags;\n"); |
862 |
< |
} |
863 |
< |
printf("\t}\n"); |
864 |
< |
return; |
865 |
< |
#endif |
866 |
< |
} |
867 |
< |
#elif defined(X86_ASSEMBLY) |
718 |
> |
/* Temporarily deleted 68k/ARM flag optimizations. I'd prefer to have |
719 |
> |
them in the appropriate m68k.h files and use just one copy of this |
720 |
> |
code here. The API can be changed if necessary. */ |
721 |
> |
#ifdef OPTIMIZED_FLAGS |
722 |
|
switch (type) { |
723 |
|
case flag_add: |
724 |
|
case flag_sub: |
725 |
|
start_brace (); |
726 |
|
printf ("\tuae_u32 %s;\n", value); |
727 |
|
break; |
874 |
– |
|
728 |
|
default: |
729 |
|
break; |
730 |
|
} |
732 |
|
/* At least some of those casts are fairly important! */ |
733 |
|
switch (type) { |
734 |
|
case flag_logical_noclobber: |
735 |
< |
printf ("\t{uae_u32 oldcznv = regflags.cznv & ~0xC0;\n"); |
735 |
> |
printf ("\t{uae_u32 oldcznv = GET_CZNV & ~(FLAGVAL_Z | FLAGVAL_N);\n"); |
736 |
|
if (strcmp (value, "0") == 0) { |
737 |
< |
printf ("\tregflags.cznv = olcznv | 64;\n"); |
737 |
> |
printf ("\tSET_CZNV (olcznv | FLAGVAL_Z);\n"); |
738 |
|
} else { |
739 |
|
switch (size) { |
740 |
< |
case sz_byte: printf ("\tx86_flag_testb ((uae_s8)(%s));\n", value); break; |
741 |
< |
case sz_word: printf ("\tx86_flag_testw ((uae_s16)(%s));\n", value); break; |
742 |
< |
case sz_long: printf ("\tx86_flag_testl ((uae_s32)(%s));\n", value); break; |
740 |
> |
case sz_byte: printf ("\toptflag_testb ((uae_s8)(%s));\n", value); break; |
741 |
> |
case sz_word: printf ("\toptflag_testw ((uae_s16)(%s));\n", value); break; |
742 |
> |
case sz_long: printf ("\toptflag_testl ((uae_s32)(%s));\n", value); break; |
743 |
|
} |
744 |
< |
printf ("\tregflags.cznv |= oldcznv;\n"); |
744 |
> |
printf ("\tIOR_CZNV (oldcznv);\n"); |
745 |
|
} |
746 |
|
printf ("\t}\n"); |
747 |
|
return; |
748 |
+ |
|
749 |
|
case flag_logical: |
750 |
|
if (strcmp (value, "0") == 0) { |
751 |
< |
printf ("\tregflags.cznv = 64;\n"); |
751 |
> |
printf ("\tSET_CZNV (FLAGVAL_Z);\n"); |
752 |
|
} else { |
753 |
|
switch (size) { |
754 |
< |
case sz_byte: printf ("\tx86_flag_testb ((uae_s8)(%s));\n", value); break; |
755 |
< |
case sz_word: printf ("\tx86_flag_testw ((uae_s16)(%s));\n", value); break; |
756 |
< |
case sz_long: printf ("\tx86_flag_testl ((uae_s32)(%s));\n", value); break; |
754 |
> |
case sz_byte: printf ("\toptflag_testb ((uae_s8)(%s));\n", value); break; |
755 |
> |
case sz_word: printf ("\toptflag_testw ((uae_s16)(%s));\n", value); break; |
756 |
> |
case sz_long: printf ("\toptflag_testl ((uae_s32)(%s));\n", value); break; |
757 |
|
} |
758 |
|
} |
759 |
|
return; |
760 |
|
|
761 |
|
case flag_add: |
762 |
|
switch (size) { |
763 |
< |
case sz_byte: printf ("\tx86_flag_addb (%s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; |
764 |
< |
case sz_word: printf ("\tx86_flag_addw (%s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; |
765 |
< |
case sz_long: printf ("\tx86_flag_addl (%s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; |
763 |
> |
case sz_byte: printf ("\toptflag_addb (%s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; |
764 |
> |
case sz_word: printf ("\toptflag_addw (%s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; |
765 |
> |
case sz_long: printf ("\toptflag_addl (%s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; |
766 |
|
} |
767 |
|
return; |
768 |
|
|
769 |
|
case flag_sub: |
770 |
|
switch (size) { |
771 |
< |
case sz_byte: printf ("\tx86_flag_subb (%s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; |
772 |
< |
case sz_word: printf ("\tx86_flag_subw (%s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; |
773 |
< |
case sz_long: printf ("\tx86_flag_subl (%s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; |
771 |
> |
case sz_byte: printf ("\toptflag_subb (%s, (uae_s8)(%s), (uae_s8)(%s));\n", value, src, dst); break; |
772 |
> |
case sz_word: printf ("\toptflag_subw (%s, (uae_s16)(%s), (uae_s16)(%s));\n", value, src, dst); break; |
773 |
> |
case sz_long: printf ("\toptflag_subl (%s, (uae_s32)(%s), (uae_s32)(%s));\n", value, src, dst); break; |
774 |
|
} |
775 |
|
return; |
776 |
|
|
777 |
|
case flag_cmp: |
778 |
|
switch (size) { |
779 |
< |
case sz_byte: printf ("\tx86_flag_cmpb ((uae_s8)(%s), (uae_s8)(%s));\n", src, dst); break; |
780 |
< |
case sz_word: printf ("\tx86_flag_cmpw ((uae_s16)(%s), (uae_s16)(%s));\n", src, dst); break; |
781 |
< |
case sz_long: printf ("\tx86_flag_cmpl ((uae_s32)(%s), (uae_s32)(%s));\n", src, dst); break; |
779 |
> |
case sz_byte: printf ("\toptflag_cmpb ((uae_s8)(%s), (uae_s8)(%s));\n", src, dst); break; |
780 |
> |
case sz_word: printf ("\toptflag_cmpw ((uae_s16)(%s), (uae_s16)(%s));\n", src, dst); break; |
781 |
> |
case sz_long: printf ("\toptflag_cmpl ((uae_s32)(%s), (uae_s32)(%s));\n", src, dst); break; |
782 |
|
} |
783 |
|
return; |
784 |
|
|
785 |
|
default: |
786 |
|
break; |
787 |
|
} |
934 |
– |
#elif defined(M68K_FLAG_OPT) |
935 |
– |
/* sam: here I'm cloning what X86_ASSEMBLY does */ |
936 |
– |
#define EXT(size) (size==sz_byte?"b":(size==sz_word?"w":"l")) |
937 |
– |
#define CAST(size) (size==sz_byte?"uae_s8":(size==sz_word?"uae_s16":"uae_s32")) |
938 |
– |
switch (type) { |
939 |
– |
case flag_add: |
940 |
– |
case flag_sub: |
941 |
– |
start_brace (); |
942 |
– |
printf ("\tuae_u32 %s;\n", value); |
943 |
– |
break; |
944 |
– |
|
945 |
– |
default: |
946 |
– |
break; |
947 |
– |
} |
948 |
– |
|
949 |
– |
switch (type) { |
950 |
– |
case flag_logical: |
951 |
– |
if (strcmp (value, "0") == 0) { |
952 |
– |
printf ("\t*(uae_u16 *)®flags = 4;\n"); /* Z = 1 */ |
953 |
– |
} else { |
954 |
– |
printf ("\tm68k_flag_tst (%s, (%s)(%s));\n", |
955 |
– |
EXT (size), CAST (size), value); |
956 |
– |
} |
957 |
– |
return; |
958 |
– |
|
959 |
– |
case flag_add: |
960 |
– |
printf ("\t{uae_u16 ccr;\n"); |
961 |
– |
printf ("\tm68k_flag_add (%s, (%s)%s, (%s)(%s), (%s)(%s));\n", |
962 |
– |
EXT (size), CAST (size), value, CAST (size), src, CAST (size), dst); |
963 |
– |
printf ("\t((uae_u16*)®flags)[1]=((uae_u16*)®flags)[0]=ccr;}\n"); |
964 |
– |
return; |
965 |
– |
|
966 |
– |
case flag_sub: |
967 |
– |
printf ("\t{uae_u16 ccr;\n"); |
968 |
– |
printf ("\tm68k_flag_sub (%s, (%s)%s, (%s)(%s), (%s)(%s));\n", |
969 |
– |
EXT (size), CAST (size), value, CAST (size), src, CAST (size), dst); |
970 |
– |
printf ("\t((uae_u16*)®flags)[1]=((uae_u16*)®flags)[0]=ccr;}\n"); |
971 |
– |
return; |
972 |
– |
|
973 |
– |
case flag_cmp: |
974 |
– |
printf ("\tm68k_flag_cmp (%s, (%s)(%s), (%s)(%s));\n", |
975 |
– |
EXT (size), CAST (size), src, CAST (size), dst); |
976 |
– |
return; |
977 |
– |
|
978 |
– |
default: |
979 |
– |
break; |
980 |
– |
} |
981 |
– |
#elif defined(ACORN_FLAG_OPT) && defined(__GNUC_MINOR__) |
982 |
– |
/* |
983 |
– |
* This is new. Might be quite buggy. |
984 |
– |
*/ |
985 |
– |
switch (type) { |
986 |
– |
case flag_av: |
987 |
– |
case flag_sv: |
988 |
– |
case flag_zn: |
989 |
– |
case flag_addx: |
990 |
– |
case flag_subx: |
991 |
– |
break; |
992 |
– |
|
993 |
– |
case flag_logical: |
994 |
– |
if (strcmp (value, "0") == 0) { |
995 |
– |
/* v=c=n=0 z=1 */ |
996 |
– |
printf ("\t*(ULONG*)®flags = 0x40000000;\n"); |
997 |
– |
return; |
998 |
– |
} else { |
999 |
– |
start_brace (); |
1000 |
– |
switch (size) { |
1001 |
– |
case sz_byte: |
1002 |
– |
printf ("\tUBYTE ccr;\n"); |
1003 |
– |
printf ("\tULONG shift;\n"); |
1004 |
– |
printf ("\t__asm__(\"mov %%2,%%1,lsl#24\n\ttst %%2,%%2\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
1005 |
– |
"\t: \"=r\" (ccr) : \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value); |
1006 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1007 |
– |
return; |
1008 |
– |
case sz_word: |
1009 |
– |
printf ("\tUBYTE ccr;\n"); |
1010 |
– |
printf ("\tULONG shift;\n"); |
1011 |
– |
printf ("\t__asm__(\"mov %%2,%%1,lsl#16\n\ttst %%2,%%2\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
1012 |
– |
"\t: \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value); |
1013 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1014 |
– |
return; |
1015 |
– |
case sz_long: |
1016 |
– |
printf ("\tUBYTE ccr;\n"); |
1017 |
– |
printf ("\t__asm__(\"tst %%1,%%1\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
1018 |
– |
"\t: \"=r\" (ccr) : \"r\" ((LONG)%s) : \"cc\" );\n", value); |
1019 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1020 |
– |
return; |
1021 |
– |
} |
1022 |
– |
} |
1023 |
– |
break; |
1024 |
– |
case flag_add: |
1025 |
– |
if (strcmp (dst, "0") == 0) { |
1026 |
– |
printf ("/* Error! Hier muss Peter noch was machen !!! (ADD-Flags) */"); |
1027 |
– |
} else { |
1028 |
– |
start_brace (); |
1029 |
– |
switch (size) { |
1030 |
– |
case sz_byte: |
1031 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1032 |
– |
printf ("\t__asm__(\"mov %%4,%%3,lsl#24\n\tadds %%0,%%4,%%2,lsl#24\n\tmov %%0,%%0,asr#24\n\tmov %%1,r15\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1033 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1034 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1035 |
– |
return; |
1036 |
– |
case sz_word: |
1037 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1038 |
– |
printf ("\t__asm__(\"mov %%4,%%3,lsl#16\n\tadds %%0,%%4,%%2,lsl#16\n\tmov %%0,%%0,asr#16\n\tmov %%1,r15\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1039 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1040 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1041 |
– |
return; |
1042 |
– |
case sz_long: |
1043 |
– |
printf ("\tULONG ccr, %s;\n", value); |
1044 |
– |
printf ("\t__asm__(\"adds %%0,%%3,%%2\n\tmov %%1,r15\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1045 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", value, src, dst); |
1046 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1047 |
– |
return; |
1048 |
– |
} |
1049 |
– |
} |
1050 |
– |
break; |
1051 |
– |
case flag_sub: |
1052 |
– |
if (strcmp (dst, "0") == 0) { |
1053 |
– |
printf ("/* Error! Hier muss Peter noch was machen !!! (SUB-Flags) */"); |
1054 |
– |
} else { |
1055 |
– |
start_brace (); |
1056 |
– |
switch (size) { |
1057 |
– |
case sz_byte: |
1058 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1059 |
– |
printf ("\t__asm__(\"mov %%4,%%3,lsl#24\n\tsubs %%0,%%4,%%2,lsl#24\n\tmov %%0,%%0,asr#24\n\tmov %%1,r15\n\teor %%1,%%1,#0x20000000\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1060 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1061 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1062 |
– |
return; |
1063 |
– |
case sz_word: |
1064 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1065 |
– |
printf ("\t__asm__(\"mov %%4,%%3,lsl#16\n\tsubs %%0,%%4,%%2,lsl#16\n\tmov %%0,%%0,asr#16\n\tmov %%1,r15\n\teor %%1,%%1,#0x20000000\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1066 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1067 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1068 |
– |
return; |
1069 |
– |
case sz_long: |
1070 |
– |
printf ("\tULONG ccr, %s;\n", value); |
1071 |
– |
printf ("\t__asm__(\"subs %%0,%%3,%%2\n\tmov %%1,r15\n\teor %%1,%%1,#0x20000000\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1072 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", value, src, dst); |
1073 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1074 |
– |
return; |
1075 |
– |
} |
1076 |
– |
} |
1077 |
– |
break; |
1078 |
– |
case flag_cmp: |
1079 |
– |
if (strcmp (dst, "0") == 0) { |
1080 |
– |
printf ("/*Error! Hier muss Peter noch was machen !!! (CMP-Flags)*/"); |
1081 |
– |
} else { |
1082 |
– |
start_brace (); |
1083 |
– |
switch (size) { |
1084 |
– |
case sz_byte: |
1085 |
– |
printf ("\tULONG shift, ccr;\n"); |
1086 |
– |
printf ("\t__asm__(\"mov %%3,%%2,lsl#24\n\tcmp %%3,%%1,lsl#24\n\tmov %%0,r15,lsr#24\n\teor %%0,%%0,#0x20\"\n" |
1087 |
– |
"\t: \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", src, dst); |
1088 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1089 |
– |
return; |
1090 |
– |
case sz_word: |
1091 |
– |
printf ("\tULONG shift, ccr;\n"); |
1092 |
– |
printf ("\t__asm__(\"mov %%3,%%2,lsl#16\n\tcmp %%3,%%1,lsl#16\n\tmov %%0,r15,lsr#24\n\teor %%0,%%0,#0x20\"\n" |
1093 |
– |
"\t: \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", src, dst); |
1094 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1095 |
– |
return; |
1096 |
– |
case sz_long: |
1097 |
– |
printf ("\tULONG ccr;\n"); |
1098 |
– |
printf ("\t__asm__(\"cmp %%2,%%1\n\tmov %%0,r15,lsr#24\n\teor %%0,%%0,#0x20\"\n" |
1099 |
– |
"\t: \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", src, dst); |
1100 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1101 |
– |
/*printf ("\tprintf (\"%%08x %%08x %%08x\\n\", %s, %s, *((ULONG*)®flags));\n", src, dst); */ |
1102 |
– |
return; |
1103 |
– |
} |
1104 |
– |
} |
1105 |
– |
break; |
1106 |
– |
} |
788 |
|
#endif |
789 |
|
genflags_normal (type, size, value, src, dst); |
790 |
|
} |
909 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
910 |
|
break; |
911 |
|
case i_SBCD: |
1231 |
– |
/* Let's hope this works... */ |
912 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0); |
913 |
|
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0); |
914 |
|
start_brace (); |
915 |
|
printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG ? 1 : 0);\n"); |
916 |
|
printf ("\tuae_u16 newv_hi = (dst & 0xF0) - (src & 0xF0);\n"); |
917 |
< |
printf ("\tuae_u16 newv;\n"); |
918 |
< |
printf ("\tint cflg;\n"); |
919 |
< |
printf ("\tif (newv_lo > 9) { newv_lo-=6; newv_hi-=0x10; }\n"); |
920 |
< |
printf ("\tnewv = newv_hi + (newv_lo & 0xF);"); |
921 |
< |
printf ("\tSET_CFLG (cflg = (newv_hi & 0x1F0) > 0x90);\n"); |
917 |
> |
printf ("\tuae_u16 newv, tmp_newv;\n"); |
918 |
> |
printf ("\tint bcd = 0;\n"); |
919 |
> |
printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n"); |
920 |
> |
printf ("\tif (newv_lo & 0xF0) { newv -= 6; bcd = 6; };\n"); |
921 |
> |
printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n"); |
922 |
> |
printf ("\tSET_CFLG ((((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG ? 1 : 0)) & 0x300) > 0xFF);\n"); |
923 |
|
duplicate_carry (); |
1243 |
– |
printf ("\tif (cflg) newv -= 0x60;\n"); |
924 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
925 |
< |
genflags (flag_sv, curi->size, "newv", "src", "dst"); |
925 |
> |
printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n"); |
926 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
927 |
|
break; |
928 |
|
case i_ADD: |
954 |
|
start_brace (); |
955 |
|
printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG ? 1 : 0);\n"); |
956 |
|
printf ("\tuae_u16 newv_hi = (src & 0xF0) + (dst & 0xF0);\n"); |
957 |
< |
printf ("\tuae_u16 newv;\n"); |
957 |
> |
printf ("\tuae_u16 newv, tmp_newv;\n"); |
958 |
|
printf ("\tint cflg;\n"); |
959 |
< |
printf ("\tif (newv_lo > 9) { newv_lo +=6; }\n"); |
960 |
< |
printf ("\tnewv = newv_hi + newv_lo;"); |
961 |
< |
printf ("\tSET_CFLG (cflg = (newv & 0x1F0) > 0x90);\n"); |
1282 |
< |
duplicate_carry (); |
959 |
> |
printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n"); |
960 |
> |
printf ("\tif (newv_lo > 9) { newv += 6; }\n"); |
961 |
> |
printf ("\tcflg = (newv & 0x3F0) > 0x90;\n"); |
962 |
|
printf ("\tif (cflg) newv += 0x60;\n"); |
963 |
+ |
printf ("\tSET_CFLG (cflg);\n"); |
964 |
+ |
duplicate_carry (); |
965 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
966 |
< |
genflags (flag_sv, curi->size, "newv", "src", "dst"); |
966 |
> |
printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n"); |
967 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
968 |
|
break; |
969 |
|
case i_NEG: |
987 |
|
printf ("\tuae_u16 newv_hi = - (src & 0xF0);\n"); |
988 |
|
printf ("\tuae_u16 newv;\n"); |
989 |
|
printf ("\tint cflg;\n"); |
990 |
< |
printf ("\tif (newv_lo > 9) { newv_lo-=6; newv_hi-=0x10; }\n"); |
991 |
< |
printf ("\tnewv = newv_hi + (newv_lo & 0xF);"); |
992 |
< |
printf ("\tSET_CFLG (cflg = (newv_hi & 0x1F0) > 0x90);\n"); |
1312 |
< |
duplicate_carry(); |
990 |
> |
printf ("\tif (newv_lo > 9) { newv_lo -= 6; }\n"); |
991 |
> |
printf ("\tnewv = newv_hi + newv_lo;\n"); |
992 |
> |
printf ("\tcflg = (newv & 0x1F0) > 0x90;\n"); |
993 |
|
printf ("\tif (cflg) newv -= 0x60;\n"); |
994 |
+ |
printf ("\tSET_CFLG (cflg);\n"); |
995 |
+ |
duplicate_carry(); |
996 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
997 |
|
genastore ("newv", curi->smode, "srcreg", curi->size, "src"); |
998 |
|
break; |
1029 |
|
else |
1030 |
|
printf ("\tsrc &= 31;\n"); |
1031 |
|
printf ("\tdst ^= (1 << src);\n"); |
1032 |
< |
printf ("\tSET_ZFLG ((dst & (1 << src)) >> src);\n"); |
1032 |
> |
printf ("\tSET_ZFLG (((uae_u32)dst & (1 << src)) >> src);\n"); |
1033 |
|
genastore ("dst", curi->dmode, "dstreg", curi->size, "dst"); |
1034 |
|
break; |
1035 |
|
case i_BCLR: |
1200 |
|
printf ("\tif ((format & 0xF000) == 0x0000) { break; }\n"); |
1201 |
|
printf ("\telse if ((format & 0xF000) == 0x1000) { ; }\n"); |
1202 |
|
printf ("\telse if ((format & 0xF000) == 0x2000) { m68k_areg(regs, 7) += 4; break; }\n"); |
1203 |
+ |
/* gb-- the next two lines are deleted in Bernie's gencpu.c */ |
1204 |
+ |
printf ("\telse if ((format & 0xF000) == 0x3000) { m68k_areg(regs, 7) += 4; break; }\n"); |
1205 |
+ |
printf ("\telse if ((format & 0xF000) == 0x7000) { m68k_areg(regs, 7) += 52; break; }\n"); |
1206 |
|
printf ("\telse if ((format & 0xF000) == 0x8000) { m68k_areg(regs, 7) += 50; break; }\n"); |
1207 |
|
printf ("\telse if ((format & 0xF000) == 0x9000) { m68k_areg(regs, 7) += 12; break; }\n"); |
1208 |
|
printf ("\telse if ((format & 0xF000) == 0xa000) { m68k_areg(regs, 7) += 24; break; }\n"); |
1219 |
|
m68k_pc_offset = 0; |
1220 |
|
break; |
1221 |
|
case i_RTD: |
1537 |
– |
printf ("\tcompiler_flush_jsr_stack();\n"); |
1222 |
|
genamode (Aipi, "7", sz_long, "pc", 1, 0); |
1223 |
|
genamode (curi->smode, "srcreg", curi->size, "offs", 1, 0); |
1224 |
|
printf ("\tm68k_areg(regs, 7) += offs;\n"); |
1252 |
|
need_endlabel = 1; |
1253 |
|
break; |
1254 |
|
case i_RTR: |
1571 |
– |
printf ("\tcompiler_flush_jsr_stack();\n"); |
1255 |
|
printf ("\tMakeSR();\n"); |
1256 |
|
genamode (Aipi, "7", sz_word, "sr", 1, 0); |
1257 |
|
genamode (Aipi, "7", sz_long, "pc", 1, 0); |
1289 |
|
m68k_pc_offset = 0; |
1290 |
|
break; |
1291 |
|
case i_Bcc: |
1292 |
+ |
if (0 && !using_prefetch && !using_exception_3 && (cpu_level >= 2)) { |
1293 |
+ |
/* gb-- variant probably more favorable to compiler optimizations |
1294 |
+ |
also assumes no prefetch buffer is used |
1295 |
+ |
Hmm, that would make sense with processors capable of conditional moves */ |
1296 |
+ |
if (curi->size == sz_long && next_cpu_level < 1) |
1297 |
+ |
next_cpu_level = 1; |
1298 |
+ |
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0); |
1299 |
+ |
printf ("\tm68k_incpc (cctrue(%d) ? ((uae_s32)src + 2) : %d);\n", curi->cc, m68k_pc_offset); |
1300 |
+ |
m68k_pc_offset = 0; |
1301 |
+ |
} |
1302 |
+ |
else { |
1303 |
+ |
/* original code for branch instructions */ |
1304 |
|
if (curi->size == sz_long) { |
1305 |
|
if (cpu_level < 2) { |
1306 |
|
printf ("\tm68k_incpc(2);\n"); |
1324 |
|
printf ("\t}\n"); |
1325 |
|
need_endlabel = 1; |
1326 |
|
} |
1632 |
– |
#ifdef USE_COMPILER |
1633 |
– |
printf ("\tm68k_setpc_bcc(m68k_getpc() + 2 + (uae_s32)src);\n"); |
1634 |
– |
#else |
1327 |
|
printf ("\tm68k_incpc ((uae_s32)src + 2);\n"); |
1636 |
– |
#endif |
1328 |
|
fill_prefetch_0 (); |
1329 |
< |
printf ("\tgoto %s;\n", endlabelstr); |
1329 |
> |
printf ("return;\n"); |
1330 |
|
printf ("didnt_jump:;\n"); |
1331 |
|
need_endlabel = 1; |
1332 |
+ |
} |
1333 |
|
break; |
1334 |
|
case i_LEA: |
1335 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 0, 0); |
1357 |
|
printf ("\t\t}\n"); |
1358 |
|
need_endlabel = 1; |
1359 |
|
} |
1668 |
– |
#ifdef USE_COMPILER |
1669 |
– |
printf ("\t\t\tm68k_setpc_bcc(m68k_getpc() + (uae_s32)offs + 2);\n"); |
1670 |
– |
#else |
1360 |
|
printf ("\t\t\tm68k_incpc((uae_s32)offs + 2);\n"); |
1672 |
– |
#endif |
1361 |
|
fill_prefetch_0 (); |
1362 |
< |
printf ("\t\tgoto %s;\n", endlabelstr); |
1362 |
> |
printf ("return;\n"); |
1363 |
|
printf ("\t\t}\n"); |
1364 |
|
printf ("\t}\n"); |
1365 |
|
need_endlabel = 1; |
1374 |
|
printf ("\tuaecptr oldpc = m68k_getpc();\n"); |
1375 |
|
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0); |
1376 |
|
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0); |
1377 |
< |
printf ("\tif(src == 0) { Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1377 |
> |
sync_m68k_pc (); |
1378 |
> |
/* Clear V flag when dividing by zero - Alcatraz Odyssey demo depends |
1379 |
> |
* on this (actually, it's doing a DIVS). */ |
1380 |
> |
printf ("\tif (src == 0) { SET_VFLG (0); Exception (5, oldpc); goto %s; } else {\n", endlabelstr); |
1381 |
|
printf ("\tuae_u32 newv = (uae_u32)dst / (uae_u32)(uae_u16)src;\n"); |
1382 |
|
printf ("\tuae_u32 rem = (uae_u32)dst %% (uae_u32)(uae_u16)src;\n"); |
1383 |
|
/* The N flag appears to be set each time there is an overflow. |
1395 |
|
printf ("\tuaecptr oldpc = m68k_getpc();\n"); |
1396 |
|
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0); |
1397 |
|
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0); |
1398 |
< |
printf ("\tif(src == 0) { Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1398 |
> |
sync_m68k_pc (); |
1399 |
> |
printf ("\tif (src == 0) { SET_VFLG (0); Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1400 |
|
printf ("\tuae_s32 newv = (uae_s32)dst / (uae_s32)(uae_s16)src;\n"); |
1401 |
|
printf ("\tuae_u16 rem = (uae_s32)dst %% (uae_s32)(uae_s16)src;\n"); |
1402 |
|
printf ("\tif ((newv & 0xffff8000) != 0 && (newv & 0xffff8000) != 0xffff8000) { SET_VFLG (1); SET_NFLG (1); SET_CFLG (0); } else\n\t{\n"); |
1457 |
|
abort (); |
1458 |
|
} |
1459 |
|
printf ("\tSET_ZFLG (upper == reg || lower == reg);\n"); |
1460 |
< |
printf ("\tSET_CFLG (lower <= upper ? reg < lower || reg > upper : reg > upper || reg < lower);\n"); |
1460 |
> |
printf ("\tSET_CFLG_ALWAYS (lower <= upper ? reg < lower || reg > upper : reg > upper || reg < lower);\n"); |
1461 |
|
printf ("\tif ((extra & 0x800) && GET_CFLG) { Exception(6,oldpc); goto %s; }\n}\n", endlabelstr); |
1462 |
|
need_endlabel = 1; |
1463 |
|
break; |
1656 |
|
} |
1657 |
|
printf ("\tcnt &= 63;\n"); |
1658 |
|
printf ("\tCLEAR_CZNV;\n"); |
1967 |
– |
if (! source_is_imm1_8 (curi)) |
1968 |
– |
force_range_for_rox ("cnt", curi->size); |
1659 |
|
if (source_is_imm1_8 (curi)) |
1660 |
|
printf ("{"); |
1661 |
< |
else |
1661 |
> |
else { |
1662 |
> |
force_range_for_rox ("cnt", curi->size); |
1663 |
|
printf ("\tif (cnt > 0) {\n"); |
1664 |
+ |
} |
1665 |
|
printf ("\tcnt--;\n"); |
1666 |
|
printf ("\t{\n\tuae_u32 carry;\n"); |
1667 |
|
printf ("\tuae_u32 loval = val >> (%d - cnt);\n", bit_size (curi->size) - 1); |
1686 |
|
} |
1687 |
|
printf ("\tcnt &= 63;\n"); |
1688 |
|
printf ("\tCLEAR_CZNV;\n"); |
1997 |
– |
if (! source_is_imm1_8 (curi)) |
1998 |
– |
force_range_for_rox ("cnt", curi->size); |
1689 |
|
if (source_is_imm1_8 (curi)) |
1690 |
|
printf ("{"); |
1691 |
< |
else |
1691 |
> |
else { |
1692 |
> |
force_range_for_rox ("cnt", curi->size); |
1693 |
|
printf ("\tif (cnt > 0) {\n"); |
1694 |
+ |
} |
1695 |
|
printf ("\tcnt--;\n"); |
1696 |
|
printf ("\t{\n\tuae_u32 carry;\n"); |
1697 |
|
printf ("\tuae_u32 hival = (val << 1) | GET_XFLG;\n"); |
1847 |
|
start_brace (); |
1848 |
|
printf ("\tint regno = (src >> 12) & 15;\n"); |
1849 |
|
printf ("\tuae_u32 *regp = regs.regs + regno;\n"); |
1850 |
< |
printf ("\tm68k_movec2(src & 0xFFF, regp);\n"); |
1850 |
> |
printf ("\tif (! m68k_movec2(src & 0xFFF, regp)) goto %s;\n", endlabelstr); |
1851 |
|
break; |
1852 |
|
case i_MOVE2C: |
1853 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0); |
1854 |
|
start_brace (); |
1855 |
|
printf ("\tint regno = (src >> 12) & 15;\n"); |
1856 |
|
printf ("\tuae_u32 *regp = regs.regs + regno;\n"); |
1857 |
< |
printf ("\tm68k_move2c(src & 0xFFF, regp);\n"); |
1857 |
> |
printf ("\tif (! m68k_move2c(src & 0xFFF, regp)) goto %s;\n", endlabelstr); |
1858 |
|
break; |
1859 |
|
case i_CAS: |
1860 |
|
{ |
1994 |
|
printf ("\ttmp = (bf0 << (offset & 7)) | (bf1 >> (8 - (offset & 7)));\n"); |
1995 |
|
} |
1996 |
|
printf ("\ttmp >>= (32 - width);\n"); |
1997 |
< |
printf ("\tSET_NFLG (tmp & (1 << (width-1)) ? 1 : 0);\n"); |
1997 |
> |
printf ("\tSET_NFLG_ALWAYS (tmp & (1 << (width-1)) ? 1 : 0);\n"); |
1998 |
|
printf ("\tSET_ZFLG (tmp == 0); SET_VFLG (0); SET_CFLG (0);\n"); |
1999 |
|
switch (curi->mnemo) { |
2000 |
|
case i_BFTST: |
2022 |
|
break; |
2023 |
|
case i_BFINS: |
2024 |
|
printf ("\ttmp = m68k_dreg(regs, (extra >> 12) & 7);\n"); |
2025 |
+ |
printf ("\tSET_NFLG_ALWAYS (tmp & (1 << (width - 1)) ? 1 : 0);\n"); |
2026 |
+ |
printf ("\tSET_ZFLG (tmp == 0);\n"); |
2027 |
|
break; |
2028 |
|
default: |
2029 |
|
break; |
2094 |
|
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0); |
2095 |
|
sync_m68k_pc (); |
2096 |
|
swap_opcode (); |
2097 |
< |
printf ("\tfpp_opp(opcode,extra);\n"); |
2097 |
> |
printf ("\tfpuop_arithmetic(opcode, extra);\n"); |
2098 |
|
break; |
2099 |
|
case i_FDBcc: |
2100 |
|
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0); |
2101 |
|
sync_m68k_pc (); |
2102 |
|
swap_opcode (); |
2103 |
< |
printf ("\tfdbcc_opp(opcode,extra);\n"); |
2103 |
> |
printf ("\tfpuop_dbcc(opcode, extra);\n"); |
2104 |
|
break; |
2105 |
|
case i_FScc: |
2106 |
|
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0); |
2107 |
|
sync_m68k_pc (); |
2108 |
|
swap_opcode (); |
2109 |
< |
printf ("\tfscc_opp(opcode,extra);\n"); |
2109 |
> |
printf ("\tfpuop_scc(opcode,extra);\n"); |
2110 |
|
break; |
2111 |
|
case i_FTRAPcc: |
2112 |
|
sync_m68k_pc (); |
2116 |
|
genamode (curi->smode, "srcreg", curi->size, "dummy", 1, 0); |
2117 |
|
sync_m68k_pc (); |
2118 |
|
swap_opcode (); |
2119 |
< |
printf ("\tftrapcc_opp(opcode,oldpc);\n"); |
2119 |
> |
printf ("\tfpuop_trapcc(opcode,oldpc);\n"); |
2120 |
|
break; |
2121 |
|
case i_FBcc: |
2122 |
|
sync_m68k_pc (); |
2125 |
|
genamode (curi->dmode, "srcreg", curi->size, "extra", 1, 0); |
2126 |
|
sync_m68k_pc (); |
2127 |
|
swap_opcode (); |
2128 |
< |
printf ("\tfbcc_opp(opcode,pc,extra);\n"); |
2128 |
> |
printf ("\tfpuop_bcc(opcode,pc,extra);\n"); |
2129 |
|
break; |
2130 |
|
case i_FSAVE: |
2131 |
|
sync_m68k_pc (); |
2132 |
|
swap_opcode (); |
2133 |
< |
printf ("\tfsave_opp(opcode);\n"); |
2133 |
> |
printf ("\tfpuop_save(opcode);\n"); |
2134 |
|
break; |
2135 |
|
case i_FRESTORE: |
2136 |
|
sync_m68k_pc (); |
2137 |
|
swap_opcode (); |
2138 |
< |
printf ("\tfrestore_opp(opcode);\n"); |
2138 |
> |
printf ("\tfpuop_restore(opcode);\n"); |
2139 |
> |
break; |
2140 |
> |
case i_CINVL: |
2141 |
> |
case i_CINVP: |
2142 |
> |
case i_CINVA: |
2143 |
> |
/* gb-- srcreg now contains the cache field */ |
2144 |
> |
printf ("\tif (srcreg&0x2)\n"); |
2145 |
> |
printf ("\t\tflush_icache(%d);\n", 30 + ((opcode >> 3) & 3)); |
2146 |
> |
break; |
2147 |
> |
case i_CPUSHL: |
2148 |
> |
case i_CPUSHP: |
2149 |
> |
case i_CPUSHA: |
2150 |
> |
/* gb-- srcreg now contains the cache field */ |
2151 |
> |
printf ("\tif (srcreg&0x2)\n"); |
2152 |
> |
printf ("\t\tflush_icache(%d);\n", 40 + ((opcode >> 3) & 3)); |
2153 |
> |
break; |
2154 |
> |
case i_MOVE16: |
2155 |
> |
if ((opcode & 0xfff8) == 0xf620) { |
2156 |
> |
/* MOVE16 (Ax)+,(Ay)+ */ |
2157 |
> |
printf ("\tuaecptr mems = m68k_areg(regs, srcreg) & ~15, memd;\n"); |
2158 |
> |
printf ("\tdstreg = (%s >> 12) & 7;\n", gen_nextiword()); |
2159 |
> |
printf ("\tmemd = m68k_areg(regs, dstreg) & ~15;\n"); |
2160 |
> |
printf ("\tput_long(memd, get_long(mems));\n"); |
2161 |
> |
printf ("\tput_long(memd+4, get_long(mems+4));\n"); |
2162 |
> |
printf ("\tput_long(memd+8, get_long(mems+8));\n"); |
2163 |
> |
printf ("\tput_long(memd+12, get_long(mems+12));\n"); |
2164 |
> |
printf ("\tif (srcreg != dstreg)\n"); |
2165 |
> |
printf ("\tm68k_areg(regs, srcreg) += 16;\n"); |
2166 |
> |
printf ("\tm68k_areg(regs, dstreg) += 16;\n"); |
2167 |
> |
} |
2168 |
> |
else { |
2169 |
> |
/* Other variants */ |
2170 |
> |
genamode (curi->smode, "srcreg", curi->size, "mems", 0, 2); |
2171 |
> |
genamode (curi->dmode, "dstreg", curi->size, "memd", 0, 2); |
2172 |
> |
printf ("\tmemsa &= ~15;\n"); |
2173 |
> |
printf ("\tmemda &= ~15;\n"); |
2174 |
> |
printf ("\tput_long(memda, get_long(memsa));\n"); |
2175 |
> |
printf ("\tput_long(memda+4, get_long(memsa+4));\n"); |
2176 |
> |
printf ("\tput_long(memda+8, get_long(memsa+8));\n"); |
2177 |
> |
printf ("\tput_long(memda+12, get_long(memsa+12));\n"); |
2178 |
> |
if ((opcode & 0xfff8) == 0xf600) |
2179 |
> |
printf ("\tm68k_areg(regs, srcreg) += 16;\n"); |
2180 |
> |
else if ((opcode & 0xfff8) == 0xf608) |
2181 |
> |
printf ("\tm68k_areg(regs, dstreg) += 16;\n"); |
2182 |
> |
} |
2183 |
|
break; |
2184 |
|
case i_MMUOP: |
2185 |
|
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0); |
2187 |
|
swap_opcode (); |
2188 |
|
printf ("\tmmu_op(opcode,extra);\n"); |
2189 |
|
break; |
2190 |
+ |
|
2191 |
+ |
case i_EMULOP_RETURN: |
2192 |
+ |
printf ("\tm68k_emulop_return();\n"); |
2193 |
+ |
m68k_pc_offset = 0; |
2194 |
+ |
break; |
2195 |
+ |
|
2196 |
+ |
case i_EMULOP: |
2197 |
+ |
printf ("\n"); |
2198 |
+ |
swap_opcode (); |
2199 |
+ |
printf ("\tm68k_emulop(opcode);\n"); |
2200 |
+ |
break; |
2201 |
+ |
|
2202 |
|
default: |
2203 |
|
abort (); |
2204 |
|
break; |
2210 |
|
static void generate_includes (FILE * f) |
2211 |
|
{ |
2212 |
|
fprintf (f, "#include \"sysdeps.h\"\n"); |
2213 |
+ |
|
2214 |
|
fprintf (f, "#include \"m68k.h\"\n"); |
2215 |
|
fprintf (f, "#include \"memory.h\"\n"); |
2216 |
|
fprintf (f, "#include \"readcpu.h\"\n"); |
2217 |
|
fprintf (f, "#include \"newcpu.h\"\n"); |
2218 |
< |
fprintf (f, "#include \"compiler.h\"\n"); |
2218 |
> |
fprintf (f, "#include \"compiler/compemu.h\"\n"); |
2219 |
> |
fprintf (f, "#include \"fpu/fpu.h\"\n"); |
2220 |
|
fprintf (f, "#include \"cputbl.h\"\n"); |
2221 |
+ |
|
2222 |
+ |
fprintf (f, "#define SET_CFLG_ALWAYS(x) SET_CFLG(x)\n"); |
2223 |
+ |
fprintf (f, "#define SET_NFLG_ALWAYS(x) SET_NFLG(x)\n"); |
2224 |
+ |
fprintf (f, "#define CPUFUNC_FF(x) x##_ff\n"); |
2225 |
+ |
fprintf (f, "#define CPUFUNC_NF(x) x##_nf\n"); |
2226 |
+ |
fprintf (f, "#define CPUFUNC(x) CPUFUNC_FF(x)\n"); |
2227 |
+ |
|
2228 |
+ |
fprintf (f, "#ifdef NOFLAGS\n"); |
2229 |
+ |
fprintf (f, "# include \"noflags.h\"\n"); |
2230 |
+ |
fprintf (f, "#endif\n"); |
2231 |
|
} |
2232 |
|
|
2233 |
|
static int postfix; |
2251 |
|
return; |
2252 |
|
|
2253 |
|
if (opcode_next_clev[rp] != cpu_level) { |
2254 |
< |
fprintf (stblfile, "{ op_%lx_%d, 0, %ld }, /* %s */\n", opcode, opcode_last_postfix[rp], |
2254 |
> |
if (table68k[opcode].flagdead == 0) |
2255 |
> |
/* force to the "ff" variant since the instruction doesn't set at all the condition codes */ |
2256 |
> |
fprintf (stblfile, "{ CPUFUNC_FF(op_%lx_%d), 0, %ld }, /* %s */\n", opcode, opcode_last_postfix[rp], |
2257 |
> |
opcode, lookuptab[i].name); |
2258 |
> |
else |
2259 |
> |
fprintf (stblfile, "{ CPUFUNC(op_%lx_%d), 0, %ld }, /* %s */\n", opcode, opcode_last_postfix[rp], |
2260 |
|
opcode, lookuptab[i].name); |
2261 |
|
return; |
2262 |
|
} |
2263 |
< |
fprintf (stblfile, "{ op_%lx_%d, 0, %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); |
2264 |
< |
fprintf (headerfile, "extern cpuop_func op_%lx_%d;\n", opcode, postfix); |
2265 |
< |
printf ("unsigned long REGPARAM2 op_%lx_%d(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2263 |
> |
|
2264 |
> |
if (table68k[opcode].flagdead == 0) |
2265 |
> |
/* force to the "ff" variant since the instruction doesn't set at all the condition codes */ |
2266 |
> |
fprintf (stblfile, "{ CPUFUNC_FF(op_%lx_%d), 0, %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); |
2267 |
> |
else |
2268 |
> |
fprintf (stblfile, "{ CPUFUNC(op_%lx_%d), 0, %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); |
2269 |
> |
|
2270 |
> |
fprintf (headerfile, "extern cpuop_func op_%lx_%d_nf;\n", opcode, postfix); |
2271 |
> |
fprintf (headerfile, "extern cpuop_func op_%lx_%d_ff;\n", opcode, postfix); |
2272 |
> |
|
2273 |
> |
/* gb-- The "nf" variant for an instruction that doesn't set the condition |
2274 |
> |
codes at all is the same as the "ff" variant, so we don't need the "nf" |
2275 |
> |
variant to be compiled since it is mapped to the "ff" variant in the |
2276 |
> |
smalltbl. */ |
2277 |
> |
if (table68k[opcode].flagdead == 0) |
2278 |
> |
printf ("#ifndef NOFLAGS\n"); |
2279 |
> |
|
2280 |
> |
printf ("void REGPARAM2 CPUFUNC(op_%lx_%d)(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2281 |
> |
printf ("\tcpuop_begin();\n"); |
2282 |
|
|
2283 |
|
switch (table68k[opcode].stype) { |
2284 |
|
case 0: smsk = 7; break; |
2287 |
|
case 3: smsk = 7; break; |
2288 |
|
case 4: smsk = 7; break; |
2289 |
|
case 5: smsk = 63; break; |
2290 |
+ |
case 6: smsk = 255; break; |
2291 |
+ |
case 7: smsk = 3; break; |
2292 |
|
default: abort (); |
2293 |
|
} |
2294 |
|
dmsk = 7; |
2298 |
|
&& table68k[opcode].smode != imm && table68k[opcode].smode != imm0 |
2299 |
|
&& table68k[opcode].smode != imm1 && table68k[opcode].smode != imm2 |
2300 |
|
&& table68k[opcode].smode != absw && table68k[opcode].smode != absl |
2301 |
< |
&& table68k[opcode].smode != PC8r && table68k[opcode].smode != PC16) |
2301 |
> |
&& table68k[opcode].smode != PC8r && table68k[opcode].smode != PC16 |
2302 |
> |
/* gb-- We don't want to fetch the EmulOp code since the EmulOp() |
2303 |
> |
routine uses the whole opcode value. Maybe all the EmulOps |
2304 |
> |
could be expanded out but I don't think it is an improvement */ |
2305 |
> |
&& table68k[opcode].stype != 6 |
2306 |
> |
) |
2307 |
|
{ |
2308 |
|
if (table68k[opcode].spos == -1) { |
2309 |
|
if (((int) table68k[opcode].sreg) >= 128) |
2399 |
|
gen_opcode (opcode); |
2400 |
|
if (need_endlabel) |
2401 |
|
printf ("%s: ;\n", endlabelstr); |
2402 |
< |
printf ("return %d;\n", insn_n_cycles); |
2402 |
> |
printf ("\tcpuop_end();\n"); |
2403 |
|
printf ("}\n"); |
2404 |
+ |
if (table68k[opcode].flagdead == 0) |
2405 |
+ |
printf ("\n#endif\n"); |
2406 |
|
opcode_next_clev[rp] = next_cpu_level; |
2407 |
|
opcode_last_postfix[rp] = postfix; |
2408 |
|
} |
2413 |
|
|
2414 |
|
using_prefetch = 0; |
2415 |
|
using_exception_3 = 0; |
2416 |
< |
for (i = 0; i < 5; i++) { |
2417 |
< |
cpu_level = 3 - i; |
2418 |
< |
if (i == 4) { |
2416 |
> |
#if !USE_PREFETCH_BUFFER |
2417 |
> |
/* gb-- No need for a prefetch buffer, nor exception 3 handling */ |
2418 |
> |
/* Anyway, Basilisk2 does not use the op_smalltbl_5 table... */ |
2419 |
> |
for (i = 0; i <= 4; i++) { |
2420 |
> |
#else |
2421 |
> |
for (i = 0; i < 6; i++) { |
2422 |
> |
#endif |
2423 |
> |
cpu_level = 4 - i; |
2424 |
> |
if (i == 5) { |
2425 |
|
cpu_level = 0; |
2426 |
|
using_prefetch = 1; |
2427 |
|
using_exception_3 = 1; |
2429 |
|
opcode_next_clev[rp] = 0; |
2430 |
|
} |
2431 |
|
postfix = i; |
2432 |
< |
fprintf (stblfile, "struct cputbl op_smalltbl_%d[] = {\n", postfix); |
2432 |
> |
fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix); |
2433 |
|
|
2434 |
|
/* sam: this is for people with low memory (eg. me :)) */ |
2435 |
|
printf ("\n" |
2463 |
|
|
2464 |
|
int main (int argc, char **argv) |
2465 |
|
{ |
2466 |
+ |
FILE *out; |
2467 |
|
read_table68k (); |
2468 |
|
do_merges (); |
2469 |
|
|
2477 |
|
* cputbl.h that way), but cpuopti can't cope. That could be fixed, but |
2478 |
|
* I don't dare to touch the 68k version. */ |
2479 |
|
|
2480 |
< |
headerfile = fopen ("cputbl.h", "wb"); |
2481 |
< |
stblfile = fopen ("cpustbl.cpp", "wb"); |
2482 |
< |
freopen ("cpuemu.cpp", "wb", stdout); |
2480 |
> |
headerfile = fopen ("cputbl.h", "w"); |
2481 |
> |
stblfile = fopen ("cpustbl.cpp", "w"); |
2482 |
> |
out = freopen ("cpuemu.cpp", "w", stdout); |
2483 |
|
|
2484 |
|
generate_includes (stdout); |
2485 |
|
generate_includes (stblfile); |
2487 |
|
generate_func (); |
2488 |
|
|
2489 |
|
free (table68k); |
2490 |
+ |
fclose (headerfile); |
2491 |
+ |
fclose (stblfile); |
2492 |
+ |
fflush (out); |
2493 |
|
return 0; |
2494 |
|
} |