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: |
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 |
|
} |
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 |
+ |
|
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: |
1231 |
– |
/* 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 (); |
1243 |
– |
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"); |
1282 |
< |
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"); |
1312 |
< |
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: |
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"); |
1967 |
– |
if (! source_is_imm1_8 (curi)) |
1968 |
– |
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"); |
1997 |
– |
if (! source_is_imm1_8 (curi)) |
1998 |
– |
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 |
|
{ |