4 |
|
* Based on work Copyright 1995, 1996 Bernd Schmidt |
5 |
|
* Changes for UAE-JIT Copyright 2000 Bernd Meyer |
6 |
|
* |
7 |
< |
* Adaptation for Basilisk II and improvements, copyright 2000-2004 |
7 |
> |
* Adaptation for Basilisk II and improvements, copyright 2000-2005 |
8 |
|
* Gwenole Beauchesne |
9 |
|
* |
10 |
< |
* Basilisk II (C) 1997-2004 Christian Bauer |
10 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
11 |
|
* |
12 |
|
* This program is free software; you can redistribute it and/or modify |
13 |
|
* it under the terms of the GNU General Public License as published by |
1100 |
|
"\tint one=scratchie++;\n" |
1101 |
|
"\tif (needed_flags&FLAG_Z) {\n" |
1102 |
|
"\tmov_l_ri(zero,0);\n" |
1103 |
< |
"\tmov_l_ri(one,1);\n" |
1103 |
> |
"\tmov_l_ri(one,-1);\n" |
1104 |
|
"\tmake_flags_live();\n" |
1105 |
|
"\tcmov_l_rr(zero,one,5);\n" |
1106 |
|
"\t}\n"); |
1123 |
|
comprintf("\tlive_flags();\n"); |
1124 |
|
comprintf("\tif (needed_flags&FLAG_Z) {\n" |
1125 |
|
"\tcmov_l_rr(zero,one,5);\n" |
1126 |
< |
"\tsetzflg_l(zero);\n" |
1126 |
> |
"\tset_zero(zero, one);\n" /* No longer need one */ |
1127 |
|
"\tlive_flags();\n" |
1128 |
|
"\t}\n"); |
1129 |
|
comprintf("\tend_needflags();\n"); |
1365 |
|
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0); |
1366 |
|
start_brace(); |
1367 |
|
comprintf("\tint s=scratchie++;\n" |
1368 |
+ |
"\tint tmp=scratchie++;\n" |
1369 |
|
"\tmov_l_rr(s,src);\n"); |
1370 |
|
if (curi->size == sz_byte) |
1371 |
|
comprintf("\tand_l_ri(s,7);\n"); |
1381 |
|
case i_BCLR: op="btr"; break; |
1382 |
|
case i_BSET: op="bts"; break; |
1383 |
|
case i_BTST: op="bt"; need_write=0; break; |
1384 |
+ |
default: abort(); |
1385 |
|
} |
1386 |
|
comprintf("\t%s_l_rr(dst,s);\n" /* Answer now in C */ |
1387 |
|
"\tsbb_l(s,s);\n" /* s is 0 if bit was 0, -1 otherwise */ |
1389 |
|
"\tdont_care_flags();\n",op); |
1390 |
|
if (!noflags) { |
1391 |
|
comprintf("\tstart_needflags();\n" |
1392 |
< |
"\tsetzflg_l(s);\n" |
1392 |
> |
"\tset_zero(s,tmp);\n" |
1393 |
|
"\tlive_flags();\n" |
1394 |
|
"\tend_needflags();\n"); |
1395 |
|
} |
1549 |
|
start_brace(); |
1550 |
|
comprintf("\tint newad=scratchie++;\n" |
1551 |
|
"\treadlong(15,newad,scratchie);\n" |
1552 |
< |
"\tmov_l_mr((uae_u32)®s.pc,newad);\n" |
1552 |
> |
"\tmov_l_mr((uintptr)®s.pc,newad);\n" |
1553 |
|
"\tget_n_addr_jmp(newad,PC_P,scratchie);\n" |
1554 |
< |
"\tmov_l_mr((uae_u32)®s.pc_oldp,PC_P);\n" |
1554 |
> |
"\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" |
1555 |
|
"\tm68k_pc_offset=0;\n" |
1556 |
|
"\tadd_l(15,offs);\n"); |
1557 |
|
gen_update_next_handler(); |
1580 |
|
case i_RTS: |
1581 |
|
comprintf("\tint newad=scratchie++;\n" |
1582 |
|
"\treadlong(15,newad,scratchie);\n" |
1583 |
< |
"\tmov_l_mr((uae_u32)®s.pc,newad);\n" |
1583 |
> |
"\tmov_l_mr((uintptr)®s.pc,newad);\n" |
1584 |
|
"\tget_n_addr_jmp(newad,PC_P,scratchie);\n" |
1585 |
< |
"\tmov_l_mr((uae_u32)®s.pc_oldp,PC_P);\n" |
1585 |
> |
"\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" |
1586 |
|
"\tm68k_pc_offset=0;\n" |
1587 |
|
"\tlea_l_brr(15,15,4);\n"); |
1588 |
|
gen_update_next_handler(); |
1605 |
|
"\tmov_l_ri(ret,retadd);\n" |
1606 |
|
"\tsub_l_ri(15,4);\n" |
1607 |
|
"\twritelong_clobber(15,ret,scratchie);\n"); |
1608 |
< |
comprintf("\tmov_l_mr((uae_u32)®s.pc,srca);\n" |
1608 |
> |
comprintf("\tmov_l_mr((uintptr)®s.pc,srca);\n" |
1609 |
|
"\tget_n_addr_jmp(srca,PC_P,scratchie);\n" |
1610 |
< |
"\tmov_l_mr((uae_u32)®s.pc_oldp,PC_P);\n" |
1610 |
> |
"\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" |
1611 |
|
"\tm68k_pc_offset=0;\n"); |
1612 |
|
gen_update_next_handler(); |
1613 |
|
break; |
1614 |
|
case i_JMP: |
1615 |
|
isjump; |
1616 |
|
genamode (curi->smode, "srcreg", curi->size, "src", 0, 0); |
1617 |
< |
comprintf("\tmov_l_mr((uae_u32)®s.pc,srca);\n" |
1617 |
> |
comprintf("\tmov_l_mr((uintptr)®s.pc,srca);\n" |
1618 |
|
"\tget_n_addr_jmp(srca,PC_P,scratchie);\n" |
1619 |
< |
"\tmov_l_mr((uae_u32)®s.pc_oldp,PC_P);\n" |
1619 |
> |
"\tmov_l_mr((uintptr)®s.pc_oldp,PC_P);\n" |
1620 |
|
"\tm68k_pc_offset=0;\n"); |
1621 |
|
gen_update_next_handler(); |
1622 |
|
break; |
1647 |
|
comprintf("\tsub_l_ri(src,m68k_pc_offset-m68k_pc_offset_thisinst-2);\n"); |
1648 |
|
/* Leave the following as "add" --- it will allow it to be optimized |
1649 |
|
away due to src being a constant ;-) */ |
1650 |
< |
comprintf("\tadd_l_ri(src,(uae_u32)comp_pc_p);\n"); |
1651 |
< |
comprintf("\tmov_l_ri(PC_P,(uae_u32)comp_pc_p);\n"); |
1650 |
> |
comprintf("\tadd_l_ri(src,(uintptr)comp_pc_p);\n"); |
1651 |
> |
comprintf("\tmov_l_ri(PC_P,(uintptr)comp_pc_p);\n"); |
1652 |
|
/* Now they are both constant. Might as well fold in m68k_pc_offset */ |
1653 |
|
comprintf("\tadd_l_ri(src,m68k_pc_offset);\n"); |
1654 |
|
comprintf("\tadd_l_ri(PC_P,m68k_pc_offset);\n"); |
1721 |
|
default: abort(); /* Seems this only comes in word flavour */ |
1722 |
|
} |
1723 |
|
comprintf("\tsub_l_ri(offs,m68k_pc_offset-m68k_pc_offset_thisinst-2);\n"); |
1724 |
< |
comprintf("\tadd_l_ri(offs,(uae_u32)comp_pc_p);\n"); /* New PC, |
1724 |
> |
comprintf("\tadd_l_ri(offs,(uintptr)comp_pc_p);\n"); /* New PC, |
1725 |
|
once the |
1726 |
|
offset_68k is |
1727 |
|
* also added */ |
2768 |
|
static void |
2769 |
|
generate_one_opcode (int rp, int noflags) |
2770 |
|
{ |
2769 |
– |
int i; |
2771 |
|
uae_u16 smsk, dmsk; |
2772 |
< |
long int opcode = opcode_map[rp]; |
2772 |
> |
const long int opcode = opcode_map[rp]; |
2773 |
> |
const char *opcode_str; |
2774 |
|
int aborted=0; |
2775 |
|
int have_srcreg=0; |
2776 |
|
int have_dstreg=0; |
2779 |
|
|| table68k[opcode].clev > cpu_level) |
2780 |
|
return; |
2781 |
|
|
2780 |
– |
for (i = 0; lookuptab[i].name[0]; i++) |
2781 |
– |
{ |
2782 |
– |
if (table68k[opcode].mnemo == lookuptab[i].mnemo) |
2783 |
– |
break; |
2784 |
– |
} |
2785 |
– |
|
2782 |
|
if (table68k[opcode].handler != -1) |
2783 |
|
return; |
2784 |
|
|
2930 |
|
comprintf("\tuae_u32 m68k_pc_offset_thisinst=m68k_pc_offset;\n"); |
2931 |
|
comprintf("\tm68k_pc_offset+=2;\n"); |
2932 |
|
|
2933 |
+ |
opcode_str = get_instruction_string (opcode); |
2934 |
+ |
|
2935 |
|
aborted=gen_opcode (opcode); |
2936 |
|
{ |
2937 |
|
int flags=0; |
2945 |
|
comprintf ("}\n"); |
2946 |
|
|
2947 |
|
if (aborted) { |
2948 |
< |
fprintf (stblfile, "{ NULL, 0x%08x, %ld }, /* %s */\n", flags, opcode, lookuptab[i].name); |
2948 |
> |
fprintf (stblfile, "{ NULL, 0x%08x, %ld }, /* %s */\n", flags, opcode, opcode_str); |
2949 |
|
com_discard(); |
2950 |
|
} |
2951 |
|
else { |
2952 |
|
if (noflags) { |
2953 |
< |
fprintf (stblfile, "{ op_%lx_%d_comp_nf, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, lookuptab[i].name); |
2953 |
> |
fprintf (stblfile, "{ op_%lx_%d_comp_nf, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, opcode_str); |
2954 |
|
fprintf (headerfile, "extern compop_func op_%lx_%d_comp_nf;\n", opcode, postfix); |
2955 |
< |
printf ("void REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2955 |
> |
printf ("void REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, opcode_str); |
2956 |
|
} |
2957 |
|
else { |
2958 |
< |
fprintf (stblfile, "{ op_%lx_%d_comp_ff, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, lookuptab[i].name); |
2958 |
> |
fprintf (stblfile, "{ op_%lx_%d_comp_ff, 0x%08x, %ld }, /* %s */\n", opcode, postfix, flags, opcode, opcode_str); |
2959 |
|
fprintf (headerfile, "extern compop_func op_%lx_%d_comp_ff;\n", opcode, postfix); |
2960 |
< |
printf ("void REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name); |
2960 |
> |
printf ("void REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, opcode_str); |
2961 |
|
} |
2962 |
|
com_flush(); |
2963 |
|
} |
3065 |
|
free (table68k); |
3066 |
|
fclose (stblfile); |
3067 |
|
fclose (headerfile); |
3068 |
+ |
fflush (stdout); |
3069 |
|
return 0; |
3070 |
|
} |