910 |
|
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst"); |
911 |
|
break; |
912 |
|
case i_SBCD: |
913 |
– |
/* 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 ("\tcflg = (newv_hi & 0x1F0) > 0x90;\n"); |
923 |
< |
printf ("\tSET_CFLG (cflg);\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 (); |
926 |
– |
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 ("\tcflg = (newv & 0x1F0) > 0x90;\n"); |
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 (); |
967 |
– |
printf ("\tif (cflg) newv += 0x60;\n"); |
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 ("\tcflg = cflg = (newv_hi & 0x1F0) > 0x90;\n"); |
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(); |
998 |
– |
printf ("\tif (cflg) newv -= 0x60;\n"); |
997 |
|
genflags (flag_zn, curi->size, "newv", "", ""); |
998 |
|
genastore ("newv", curi->smode, "srcreg", curi->size, "src"); |
999 |
|
break; |