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: |
721 |
< |
start_brace(); |
722 |
< |
printf("\tuae_u32 %s;\n", value); |
723 |
< |
switch(size) |
724 |
< |
{ |
725 |
< |
case sz_byte: |
726 |
< |
printf("\t%s = sparc_v8_flag_add_8(M68K_FLAGS_ADDR, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
727 |
< |
break; |
728 |
< |
case sz_word: |
729 |
< |
printf("\t%s = sparc_v8_flag_add_16(M68K_FLAGS_ADDR, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
730 |
< |
break; |
731 |
< |
case sz_long: |
732 |
< |
printf("\t%s = sparc_v8_flag_add_32(M68K_FLAGS_ADDR, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
733 |
< |
break; |
734 |
< |
} |
735 |
< |
return; |
736 |
< |
} |
737 |
< |
#elif defined(SPARC_V9_ASSEMBLY) |
738 |
< |
switch(type) |
739 |
< |
{ |
740 |
< |
case flag_add: |
741 |
< |
start_brace(); |
742 |
< |
printf("\tuae_u32 %s;\n", value); |
743 |
< |
switch(size) |
744 |
< |
{ |
745 |
< |
case sz_byte: |
746 |
< |
printf("\t%s = sparc_v9_flag_add_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
747 |
< |
break; |
748 |
< |
case sz_word: |
749 |
< |
printf("\t%s = sparc_v9_flag_add_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
750 |
< |
break; |
751 |
< |
case sz_long: |
752 |
< |
printf("\t%s = sparc_v9_flag_add_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
753 |
< |
break; |
754 |
< |
} |
755 |
< |
return; |
756 |
< |
|
757 |
< |
case flag_sub: |
758 |
< |
start_brace(); |
759 |
< |
printf("\tuae_u32 %s;\n", value); |
760 |
< |
switch(size) |
761 |
< |
{ |
762 |
< |
case sz_byte: |
763 |
< |
printf("\t%s = sparc_v9_flag_sub_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
764 |
< |
break; |
765 |
< |
case sz_word: |
766 |
< |
printf("\t%s = sparc_v9_flag_sub_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
767 |
< |
break; |
768 |
< |
case sz_long: |
769 |
< |
printf("\t%s = sparc_v9_flag_sub_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", value, src, dst); |
770 |
< |
break; |
771 |
< |
} |
772 |
< |
return; |
773 |
< |
|
774 |
< |
case flag_cmp: |
775 |
< |
switch(size) |
776 |
< |
{ |
777 |
< |
case sz_byte: |
778 |
< |
printf("\tsparc_v9_flag_cmp_8(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
779 |
< |
break; |
780 |
< |
case sz_word: |
781 |
< |
printf("\tsparc_v9_flag_cmp_16(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
782 |
< |
break; |
783 |
< |
case sz_long: |
784 |
< |
printf("\tsparc_v9_flag_cmp_32(®flags, (uae_u32)(%s), (uae_u32)(%s));\n", src, dst); |
785 |
< |
break; |
786 |
< |
} |
787 |
< |
return; |
788 |
< |
|
789 |
< |
case flag_logical: |
790 |
< |
if (strcmp(value, "0") == 0) { |
791 |
< |
printf("\tregflags.nzvc = 0x04;\n"); |
792 |
< |
} else { |
793 |
< |
switch(size) { |
794 |
< |
case sz_byte: |
795 |
< |
printf("\tsparc_v9_flag_test_8(®flags, (uae_u32)(%s));\n", value); |
796 |
< |
break; |
797 |
< |
case sz_word: |
798 |
< |
printf("\tsparc_v9_flag_test_16(®flags, (uae_u32)(%s));\n", value); |
799 |
< |
break; |
800 |
< |
case sz_long: |
801 |
< |
printf("\tsparc_v9_flag_test_32(®flags, (uae_u32)(%s));\n", value); |
802 |
< |
break; |
803 |
< |
} |
804 |
< |
} |
805 |
< |
return; |
806 |
< |
|
807 |
< |
#if 0 |
808 |
< |
case flag_logical_noclobber: |
809 |
< |
printf("\t{uae_u32 old_flags = regflags.nzvc & ~0x0C;\n"); |
810 |
< |
if (strcmp(value, "0") == 0) { |
811 |
< |
printf("\tregflags.nzvc = old_flags | 0x04;\n"); |
812 |
< |
} else { |
813 |
< |
switch(size) { |
814 |
< |
case sz_byte: |
815 |
< |
printf("\tsparc_v9_flag_test_8(®flags, (uae_u32)(%s));\n", value); |
816 |
< |
break; |
817 |
< |
case sz_word: |
818 |
< |
printf("\tsparc_v9_flag_test_16(®flags, (uae_u32)(%s));\n", value); |
819 |
< |
break; |
820 |
< |
case sz_long: |
821 |
< |
printf("\tsparc_v9_flag_test_32(®flags, (uae_u32)(%s));\n", value); |
822 |
< |
break; |
823 |
< |
} |
824 |
< |
printf("\tregflags.nzvc |= old_flags;\n"); |
825 |
< |
} |
826 |
< |
printf("\t}\n"); |
827 |
< |
return; |
828 |
< |
#endif |
829 |
< |
} |
830 |
< |
#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: |
733 |
|
/* At least some of those casts are fairly important! */ |
734 |
|
switch (type) { |
735 |
|
case flag_logical_noclobber: |
736 |
< |
printf ("\t{uae_u32 oldcznv = regflags.cznv & ~0xC0;\n"); |
736 |
> |
printf ("\t{uae_u32 oldcznv = GET_CZNV & ~(FLAGVAL_Z | FLAGVAL_N);\n"); |
737 |
|
if (strcmp (value, "0") == 0) { |
738 |
< |
printf ("\tregflags.cznv = olcznv | 64;\n"); |
738 |
> |
printf ("\tSET_CZNV (olcznv | FLAGVAL_Z);\n"); |
739 |
|
} else { |
740 |
|
switch (size) { |
741 |
< |
case sz_byte: printf ("\tx86_flag_testb ((uae_s8)(%s));\n", value); break; |
742 |
< |
case sz_word: printf ("\tx86_flag_testw ((uae_s16)(%s));\n", value); break; |
743 |
< |
case sz_long: printf ("\tx86_flag_testl ((uae_s32)(%s));\n", value); break; |
741 |
> |
case sz_byte: printf ("\toptflag_testb ((uae_s8)(%s));\n", value); break; |
742 |
> |
case sz_word: printf ("\toptflag_testw ((uae_s16)(%s));\n", value); break; |
743 |
> |
case sz_long: printf ("\toptflag_testl ((uae_s32)(%s));\n", value); break; |
744 |
|
} |
745 |
< |
printf ("\tregflags.cznv |= oldcznv;\n"); |
745 |
> |
printf ("\tIOR_CZNV (oldcznv);\n"); |
746 |
|
} |
747 |
|
printf ("\t}\n"); |
748 |
|
return; |
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 |
|
} |
897 |
– |
#elif defined(M68K_FLAG_OPT) |
898 |
– |
/* sam: here I'm cloning what X86_ASSEMBLY does */ |
899 |
– |
#define EXT(size) (size==sz_byte?"b":(size==sz_word?"w":"l")) |
900 |
– |
#define CAST(size) (size==sz_byte?"uae_s8":(size==sz_word?"uae_s16":"uae_s32")) |
901 |
– |
switch (type) { |
902 |
– |
case flag_add: |
903 |
– |
case flag_sub: |
904 |
– |
start_brace (); |
905 |
– |
printf ("\tuae_u32 %s;\n", value); |
906 |
– |
break; |
907 |
– |
|
908 |
– |
default: |
909 |
– |
break; |
910 |
– |
} |
911 |
– |
|
912 |
– |
switch (type) { |
913 |
– |
case flag_logical: |
914 |
– |
if (strcmp (value, "0") == 0) { |
915 |
– |
printf ("\t*(uae_u16 *)®flags = 4;\n"); /* Z = 1 */ |
916 |
– |
} else { |
917 |
– |
printf ("\tm68k_flag_tst (%s, (%s)(%s));\n", |
918 |
– |
EXT (size), CAST (size), value); |
919 |
– |
} |
920 |
– |
return; |
921 |
– |
|
922 |
– |
case flag_add: |
923 |
– |
printf ("\t{uae_u16 ccr;\n"); |
924 |
– |
printf ("\tm68k_flag_add (%s, (%s)%s, (%s)(%s), (%s)(%s));\n", |
925 |
– |
EXT (size), CAST (size), value, CAST (size), src, CAST (size), dst); |
926 |
– |
printf ("\t((uae_u16*)®flags)[1]=((uae_u16*)®flags)[0]=ccr;}\n"); |
927 |
– |
return; |
928 |
– |
|
929 |
– |
case flag_sub: |
930 |
– |
printf ("\t{uae_u16 ccr;\n"); |
931 |
– |
printf ("\tm68k_flag_sub (%s, (%s)%s, (%s)(%s), (%s)(%s));\n", |
932 |
– |
EXT (size), CAST (size), value, CAST (size), src, CAST (size), dst); |
933 |
– |
printf ("\t((uae_u16*)®flags)[1]=((uae_u16*)®flags)[0]=ccr;}\n"); |
934 |
– |
return; |
935 |
– |
|
936 |
– |
case flag_cmp: |
937 |
– |
printf ("\tm68k_flag_cmp (%s, (%s)(%s), (%s)(%s));\n", |
938 |
– |
EXT (size), CAST (size), src, CAST (size), dst); |
939 |
– |
return; |
940 |
– |
|
941 |
– |
default: |
942 |
– |
break; |
943 |
– |
} |
944 |
– |
#elif defined(ACORN_FLAG_OPT) && defined(__GNUC_MINOR__) |
945 |
– |
/* |
946 |
– |
* This is new. Might be quite buggy. |
947 |
– |
*/ |
948 |
– |
switch (type) { |
949 |
– |
case flag_av: |
950 |
– |
case flag_sv: |
951 |
– |
case flag_zn: |
952 |
– |
case flag_addx: |
953 |
– |
case flag_subx: |
954 |
– |
break; |
955 |
– |
|
956 |
– |
case flag_logical: |
957 |
– |
if (strcmp (value, "0") == 0) { |
958 |
– |
/* v=c=n=0 z=1 */ |
959 |
– |
printf ("\t*(ULONG*)®flags = 0x40000000;\n"); |
960 |
– |
return; |
961 |
– |
} else { |
962 |
– |
start_brace (); |
963 |
– |
switch (size) { |
964 |
– |
case sz_byte: |
965 |
– |
printf ("\tUBYTE ccr;\n"); |
966 |
– |
printf ("\tULONG shift;\n"); |
967 |
– |
printf ("\t__asm__(\"mov %%2,%%1,lsl#24\n\ttst %%2,%%2\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
968 |
– |
"\t: \"=r\" (ccr) : \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value); |
969 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
970 |
– |
return; |
971 |
– |
case sz_word: |
972 |
– |
printf ("\tUBYTE ccr;\n"); |
973 |
– |
printf ("\tULONG shift;\n"); |
974 |
– |
printf ("\t__asm__(\"mov %%2,%%1,lsl#16\n\ttst %%2,%%2\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
975 |
– |
"\t: \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value); |
976 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
977 |
– |
return; |
978 |
– |
case sz_long: |
979 |
– |
printf ("\tUBYTE ccr;\n"); |
980 |
– |
printf ("\t__asm__(\"tst %%1,%%1\n\tmov %%0,r15,lsr#24\n\tbic %%0,%%0,#0x30\"\n" |
981 |
– |
"\t: \"=r\" (ccr) : \"r\" ((LONG)%s) : \"cc\" );\n", value); |
982 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
983 |
– |
return; |
984 |
– |
} |
985 |
– |
} |
986 |
– |
break; |
987 |
– |
case flag_add: |
988 |
– |
if (strcmp (dst, "0") == 0) { |
989 |
– |
printf ("/* Error! Hier muss Peter noch was machen !!! (ADD-Flags) */"); |
990 |
– |
} else { |
991 |
– |
start_brace (); |
992 |
– |
switch (size) { |
993 |
– |
case sz_byte: |
994 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
995 |
– |
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" |
996 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
997 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
998 |
– |
return; |
999 |
– |
case sz_word: |
1000 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1001 |
– |
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" |
1002 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1003 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1004 |
– |
return; |
1005 |
– |
case sz_long: |
1006 |
– |
printf ("\tULONG ccr, %s;\n", value); |
1007 |
– |
printf ("\t__asm__(\"adds %%0,%%3,%%2\n\tmov %%1,r15\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1008 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", value, src, dst); |
1009 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1010 |
– |
return; |
1011 |
– |
} |
1012 |
– |
} |
1013 |
– |
break; |
1014 |
– |
case flag_sub: |
1015 |
– |
if (strcmp (dst, "0") == 0) { |
1016 |
– |
printf ("/* Error! Hier muss Peter noch was machen !!! (SUB-Flags) */"); |
1017 |
– |
} else { |
1018 |
– |
start_brace (); |
1019 |
– |
switch (size) { |
1020 |
– |
case sz_byte: |
1021 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1022 |
– |
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" |
1023 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1024 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1025 |
– |
return; |
1026 |
– |
case sz_word: |
1027 |
– |
printf ("\tULONG ccr, shift, %s;\n", value); |
1028 |
– |
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" |
1029 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", value, src, dst); |
1030 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1031 |
– |
return; |
1032 |
– |
case sz_long: |
1033 |
– |
printf ("\tULONG ccr, %s;\n", value); |
1034 |
– |
printf ("\t__asm__(\"subs %%0,%%3,%%2\n\tmov %%1,r15\n\teor %%1,%%1,#0x20000000\n\torr %%1,%%1,%%1,lsr#29\"\n" |
1035 |
– |
"\t: \"=r\" (%s), \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", value, src, dst); |
1036 |
– |
printf ("\t*(ULONG*)®flags = ccr;\n"); |
1037 |
– |
return; |
1038 |
– |
} |
1039 |
– |
} |
1040 |
– |
break; |
1041 |
– |
case flag_cmp: |
1042 |
– |
if (strcmp (dst, "0") == 0) { |
1043 |
– |
printf ("/*Error! Hier muss Peter noch was machen !!! (CMP-Flags)*/"); |
1044 |
– |
} else { |
1045 |
– |
start_brace (); |
1046 |
– |
switch (size) { |
1047 |
– |
case sz_byte: |
1048 |
– |
printf ("\tULONG shift, ccr;\n"); |
1049 |
– |
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" |
1050 |
– |
"\t: \"=r\" (ccr) : \"r\" (%s), \"r\" (%s), \"r\" (shift) : \"cc\" );\n", src, dst); |
1051 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1052 |
– |
return; |
1053 |
– |
case sz_word: |
1054 |
– |
printf ("\tULONG shift, ccr;\n"); |
1055 |
– |
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" |
1056 |
– |
"\t: \"=r\" (ccr) : \"r\" ((WORD)%s), \"r\" ((WORD)%s), \"r\" (shift) : \"cc\" );\n", src, dst); |
1057 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1058 |
– |
return; |
1059 |
– |
case sz_long: |
1060 |
– |
printf ("\tULONG ccr;\n"); |
1061 |
– |
printf ("\t__asm__(\"cmp %%2,%%1\n\tmov %%0,r15,lsr#24\n\teor %%0,%%0,#0x20\"\n" |
1062 |
– |
"\t: \"=r\" (ccr) : \"r\" ((LONG)%s), \"r\" ((LONG)%s) : \"cc\" );\n", src, dst); |
1063 |
– |
printf ("\t*((UBYTE*)®flags+3) = ccr;\n"); |
1064 |
– |
/*printf ("\tprintf (\"%%08x %%08x %%08x\\n\", %s, %s, *((ULONG*)®flags));\n", src, dst); */ |
1065 |
– |
return; |
1066 |
– |
} |
1067 |
– |
} |
1068 |
– |
break; |
1069 |
– |
} |
788 |
|
#endif |
789 |
+ |
|
790 |
|
genflags_normal (type, size, value, src, dst); |
791 |
|
} |
792 |
|
|
910 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
911 |
|
break; |
912 |
|
case i_SBCD: |
1194 |
– |
/* Let's hope this works... */ |
913 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0); |
914 |
|
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0); |
915 |
|
start_brace (); |
916 |
|
printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG ? 1 : 0);\n"); |
917 |
|
printf ("\tuae_u16 newv_hi = (dst & 0xF0) - (src & 0xF0);\n"); |
918 |
< |
printf ("\tuae_u16 newv;\n"); |
919 |
< |
printf ("\tint cflg;\n"); |
920 |
< |
printf ("\tif (newv_lo > 9) { newv_lo-=6; newv_hi-=0x10; }\n"); |
921 |
< |
printf ("\tnewv = newv_hi + (newv_lo & 0xF);"); |
922 |
< |
printf ("\tSET_CFLG (cflg = (newv_hi & 0x1F0) > 0x90);\n"); |
918 |
> |
printf ("\tuae_u16 newv, tmp_newv;\n"); |
919 |
> |
printf ("\tint bcd = 0;\n"); |
920 |
> |
printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n"); |
921 |
> |
printf ("\tif (newv_lo & 0xF0) { newv -= 6; bcd = 6; };\n"); |
922 |
> |
printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n"); |
923 |
> |
printf ("\tSET_CFLG ((((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG ? 1 : 0)) & 0x300) > 0xFF);\n"); |
924 |
|
duplicate_carry (); |
1206 |
– |
printf ("\tif (cflg) newv -= 0x60;\n"); |
925 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
926 |
< |
genflags (flag_sv, curi->size, "newv", "src", "dst"); |
926 |
> |
printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n"); |
927 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
928 |
|
break; |
929 |
|
case i_ADD: |
955 |
|
start_brace (); |
956 |
|
printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG ? 1 : 0);\n"); |
957 |
|
printf ("\tuae_u16 newv_hi = (src & 0xF0) + (dst & 0xF0);\n"); |
958 |
< |
printf ("\tuae_u16 newv;\n"); |
958 |
> |
printf ("\tuae_u16 newv, tmp_newv;\n"); |
959 |
|
printf ("\tint cflg;\n"); |
960 |
< |
printf ("\tif (newv_lo > 9) { newv_lo +=6; }\n"); |
961 |
< |
printf ("\tnewv = newv_hi + newv_lo;"); |
962 |
< |
printf ("\tSET_CFLG (cflg = (newv & 0x1F0) > 0x90);\n"); |
1245 |
< |
duplicate_carry (); |
960 |
> |
printf ("\tnewv = tmp_newv = newv_hi + newv_lo;"); |
961 |
> |
printf ("\tif (newv_lo > 9) { newv += 6; }\n"); |
962 |
> |
printf ("\tcflg = (newv & 0x3F0) > 0x90;\n"); |
963 |
|
printf ("\tif (cflg) newv += 0x60;\n"); |
964 |
+ |
printf ("\tSET_CFLG (cflg);\n"); |
965 |
+ |
duplicate_carry (); |
966 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
967 |
< |
genflags (flag_sv, curi->size, "newv", "src", "dst"); |
967 |
> |
printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n"); |
968 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
969 |
|
break; |
970 |
|
case i_NEG: |
988 |
|
printf ("\tuae_u16 newv_hi = - (src & 0xF0);\n"); |
989 |
|
printf ("\tuae_u16 newv;\n"); |
990 |
|
printf ("\tint cflg;\n"); |
991 |
< |
printf ("\tif (newv_lo > 9) { newv_lo-=6; newv_hi-=0x10; }\n"); |
992 |
< |
printf ("\tnewv = newv_hi + (newv_lo & 0xF);"); |
993 |
< |
printf ("\tSET_CFLG (cflg = (newv_hi & 0x1F0) > 0x90);\n"); |
1275 |
< |
duplicate_carry(); |
991 |
> |
printf ("\tif (newv_lo > 9) { newv_lo -= 6; }\n"); |
992 |
> |
printf ("\tnewv = newv_hi + newv_lo;"); |
993 |
> |
printf ("\tcflg = (newv & 0x1F0) > 0x90;\n"); |
994 |
|
printf ("\tif (cflg) newv -= 0x60;\n"); |
995 |
+ |
printf ("\tSET_CFLG (cflg);\n"); |
996 |
+ |
duplicate_carry(); |
997 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
998 |
|
genastore ("newv", curi->smode, "srcreg", curi->size, "src"); |
999 |
|
break; |
1030 |
|
else |
1031 |
|
printf ("\tsrc &= 31;\n"); |
1032 |
|
printf ("\tdst ^= (1 << src);\n"); |
1033 |
< |
printf ("\tSET_ZFLG ((dst & (1 << src)) >> src);\n"); |
1033 |
> |
printf ("\tSET_ZFLG (((uae_u32)dst & (1 << src)) >> src);\n"); |
1034 |
|
genastore ("dst", curi->dmode, "dstreg", curi->size, "dst"); |
1035 |
|
break; |
1036 |
|
case i_BCLR: |
1219 |
|
m68k_pc_offset = 0; |
1220 |
|
break; |
1221 |
|
case i_RTD: |
1502 |
– |
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: |
1536 |
– |
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); |
1369 |
|
printf ("\tuaecptr oldpc = m68k_getpc();\n"); |
1370 |
|
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0); |
1371 |
|
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0); |
1372 |
< |
printf ("\tif(src == 0) { Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1372 |
> |
sync_m68k_pc (); |
1373 |
> |
/* Clear V flag when dividing by zero - Alcatraz Odyssey demo depends |
1374 |
> |
* on this (actually, it's doing a DIVS). */ |
1375 |
> |
printf ("\tif (src == 0) { SET_VFLG (0); Exception (5, oldpc); goto %s; } else {\n", endlabelstr); |
1376 |
|
printf ("\tuae_u32 newv = (uae_u32)dst / (uae_u32)(uae_u16)src;\n"); |
1377 |
|
printf ("\tuae_u32 rem = (uae_u32)dst %% (uae_u32)(uae_u16)src;\n"); |
1378 |
|
/* The N flag appears to be set each time there is an overflow. |
1390 |
|
printf ("\tuaecptr oldpc = m68k_getpc();\n"); |
1391 |
|
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0); |
1392 |
|
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0); |
1393 |
< |
printf ("\tif(src == 0) { Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1393 |
> |
sync_m68k_pc (); |
1394 |
> |
printf ("\tif (src == 0) { SET_VFLG (0); Exception(5,oldpc); goto %s; } else {\n", endlabelstr); |
1395 |
|
printf ("\tuae_s32 newv = (uae_s32)dst / (uae_s32)(uae_s16)src;\n"); |
1396 |
|
printf ("\tuae_u16 rem = (uae_s32)dst %% (uae_s32)(uae_s16)src;\n"); |
1397 |
|
printf ("\tif ((newv & 0xffff8000) != 0 && (newv & 0xffff8000) != 0xffff8000) { SET_VFLG (1); SET_NFLG (1); SET_CFLG (0); } else\n\t{\n"); |
1651 |
|
} |
1652 |
|
printf ("\tcnt &= 63;\n"); |
1653 |
|
printf ("\tCLEAR_CZNV;\n"); |
1932 |
– |
if (! source_is_imm1_8 (curi)) |
1933 |
– |
force_range_for_rox ("cnt", curi->size); |
1654 |
|
if (source_is_imm1_8 (curi)) |
1655 |
|
printf ("{"); |
1656 |
< |
else |
1656 |
> |
else { |
1657 |
> |
force_range_for_rox ("cnt", curi->size); |
1658 |
|
printf ("\tif (cnt > 0) {\n"); |
1659 |
+ |
} |
1660 |
|
printf ("\tcnt--;\n"); |
1661 |
|
printf ("\t{\n\tuae_u32 carry;\n"); |
1662 |
|
printf ("\tuae_u32 loval = val >> (%d - cnt);\n", bit_size (curi->size) - 1); |
1681 |
|
} |
1682 |
|
printf ("\tcnt &= 63;\n"); |
1683 |
|
printf ("\tCLEAR_CZNV;\n"); |
1962 |
– |
if (! source_is_imm1_8 (curi)) |
1963 |
– |
force_range_for_rox ("cnt", curi->size); |
1684 |
|
if (source_is_imm1_8 (curi)) |
1685 |
|
printf ("{"); |
1686 |
< |
else |
1686 |
> |
else { |
1687 |
> |
force_range_for_rox ("cnt", curi->size); |
1688 |
|
printf ("\tif (cnt > 0) {\n"); |
1689 |
+ |
} |
1690 |
|
printf ("\tcnt--;\n"); |
1691 |
|
printf ("\t{\n\tuae_u32 carry;\n"); |
1692 |
|
printf ("\tuae_u32 hival = (val << 1) | GET_XFLG;\n"); |
1842 |
|
start_brace (); |
1843 |
|
printf ("\tint regno = (src >> 12) & 15;\n"); |
1844 |
|
printf ("\tuae_u32 *regp = regs.regs + regno;\n"); |
1845 |
< |
printf ("\tm68k_movec2(src & 0xFFF, regp);\n"); |
1845 |
> |
printf ("\tif (! m68k_movec2(src & 0xFFF, regp)) goto %s;\n", endlabelstr); |
1846 |
|
break; |
1847 |
|
case i_MOVE2C: |
1848 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0); |
1849 |
|
start_brace (); |
1850 |
|
printf ("\tint regno = (src >> 12) & 15;\n"); |
1851 |
|
printf ("\tuae_u32 *regp = regs.regs + regno;\n"); |
1852 |
< |
printf ("\tm68k_move2c(src & 0xFFF, regp);\n"); |
1852 |
> |
printf ("\tif (! m68k_move2c(src & 0xFFF, regp)) goto %s;\n", endlabelstr); |
1853 |
|
break; |
1854 |
|
case i_CAS: |
1855 |
|
{ |
2138 |
|
case i_CPUSHA: |
2139 |
|
break; |
2140 |
|
case i_MOVE16: |
2141 |
< |
printf ("\tuaecptr mems = m68k_areg(regs, srcreg) & ~15, memd;\n"); |
2142 |
< |
printf ("\tdstreg = (%s >> 12) & 7;\n", gen_nextiword()); |
2143 |
< |
printf ("\tmemd = m68k_areg(regs, dstreg) & ~15;\n"); |
2144 |
< |
printf ("\tput_long(memd, get_long(mems));\n"); |
2145 |
< |
printf ("\tput_long(memd+4, get_long(mems+4));\n"); |
2146 |
< |
printf ("\tput_long(memd+8, get_long(mems+8));\n"); |
2147 |
< |
printf ("\tput_long(memd+12, get_long(mems+12));\n"); |
2148 |
< |
printf ("\tm68k_areg(regs, srcreg) += 16;\n"); |
2149 |
< |
printf ("\tm68k_areg(regs, dstreg) += 16;\n"); |
2141 |
> |
if ((opcode & 0xfff8) == 0xf620) { |
2142 |
> |
/* MOVE16 (Ax)+,(Ay)+ */ |
2143 |
> |
printf ("\tuaecptr mems = m68k_areg(regs, srcreg) & ~15, memd;\n"); |
2144 |
> |
printf ("\tdstreg = (%s >> 12) & 7;\n", gen_nextiword()); |
2145 |
> |
printf ("\tmemd = m68k_areg(regs, dstreg) & ~15;\n"); |
2146 |
> |
printf ("\tput_long(memd, get_long(mems));\n"); |
2147 |
> |
printf ("\tput_long(memd+4, get_long(mems+4));\n"); |
2148 |
> |
printf ("\tput_long(memd+8, get_long(mems+8));\n"); |
2149 |
> |
printf ("\tput_long(memd+12, get_long(mems+12));\n"); |
2150 |
> |
printf ("\tif (srcreg != dstreg)\n"); |
2151 |
> |
printf ("\tm68k_areg(regs, srcreg) += 16;\n"); |
2152 |
> |
printf ("\tm68k_areg(regs, dstreg) += 16;\n"); |
2153 |
> |
} |
2154 |
> |
else { |
2155 |
> |
/* Other variants */ |
2156 |
> |
genamode (curi->smode, "srcreg", curi->size, "mems", 0, 2); |
2157 |
> |
genamode (curi->dmode, "dstreg", curi->size, "memd", 0, 2); |
2158 |
> |
printf ("\tmemsa &= ~15;\n"); |
2159 |
> |
printf ("\tmemda &= ~15;\n"); |
2160 |
> |
printf ("\tput_long(memda, get_long(memsa));\n"); |
2161 |
> |
printf ("\tput_long(memda+4, get_long(memsa+4));\n"); |
2162 |
> |
printf ("\tput_long(memda+8, get_long(memsa+8));\n"); |
2163 |
> |
printf ("\tput_long(memda+12, get_long(memsa+12));\n"); |
2164 |
> |
if ((opcode & 0xfff8) == 0xf600) |
2165 |
> |
printf ("\tm68k_areg(regs, srcreg) += 16;\n"); |
2166 |
> |
else if ((opcode & 0xfff8) == 0xf608) |
2167 |
> |
printf ("\tm68k_areg(regs, dstreg) += 16;\n"); |
2168 |
> |
} |
2169 |
|
break; |
2170 |
|
case i_MMUOP: |
2171 |
|
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0); |
2188 |
|
fprintf (f, "#include \"memory.h\"\n"); |
2189 |
|
fprintf (f, "#include \"readcpu.h\"\n"); |
2190 |
|
fprintf (f, "#include \"newcpu.h\"\n"); |
2450 |
– |
fprintf (f, "#include \"compiler.h\"\n"); |
2191 |
|
fprintf (f, "#include \"cputbl.h\"\n"); |
2192 |
|
} |
2193 |
|
|
2218 |
|
} |
2219 |
|
fprintf (stblfile, "{ op_%lx_%d, 0, %ld }, /* %s */\n", opcode, postfix, opcode, lookuptab[i].name); |
2220 |
|
fprintf (headerfile, "extern cpuop_func op_%lx_%d;\n", opcode, postfix); |
2221 |
< |
printf ("unsigned long REGPARAM2 op_%lx_%d(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2221 |
> |
printf ("void REGPARAM2 op_%lx_%d(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2222 |
|
|
2223 |
|
switch (table68k[opcode].stype) { |
2224 |
|
case 0: smsk = 7; break; |
2227 |
|
case 3: smsk = 7; break; |
2228 |
|
case 4: smsk = 7; break; |
2229 |
|
case 5: smsk = 63; break; |
2230 |
+ |
case 7: smsk = 3; break; |
2231 |
|
default: abort (); |
2232 |
|
} |
2233 |
|
dmsk = 7; |
2333 |
|
gen_opcode (opcode); |
2334 |
|
if (need_endlabel) |
2335 |
|
printf ("%s: ;\n", endlabelstr); |
2595 |
– |
printf ("return %d;\n", insn_n_cycles); |
2336 |
|
printf ("}\n"); |
2337 |
|
opcode_next_clev[rp] = next_cpu_level; |
2338 |
|
opcode_last_postfix[rp] = postfix; |
2344 |
|
|
2345 |
|
using_prefetch = 0; |
2346 |
|
using_exception_3 = 0; |
2347 |
+ |
#if !USE_PREFETCH_BUFFER |
2348 |
+ |
/* gb-- No need for a prefetch buffer, nor exception 3 handling */ |
2349 |
+ |
/* Anyway, Basilisk2 does not use the op_smalltbl_5 table... */ |
2350 |
+ |
for (i = 0; i <= 4; i++) { |
2351 |
+ |
#else |
2352 |
|
for (i = 0; i < 6; i++) { |
2353 |
+ |
#endif |
2354 |
|
cpu_level = 4 - i; |
2355 |
|
if (i == 5) { |
2356 |
|
cpu_level = 0; |