--- uae/src/genp2c.c 2018/04/24 16:39:50 1.1 +++ uae/src/genp2c.c 2018/04/24 17:14:08 1.1.1.5 @@ -12,7 +12,9 @@ #include "sysconfig.h" #include "sysdeps.h" -#include "custom.h" +/* We can't include custom.h here. */ +#define MAX_WORDS_PER_LINE 50 + static char *gen_ind (char *a, int b) { @@ -38,7 +40,11 @@ static char *gen_indsx (char *a, char *s #define reg(a) "%" a #define ind(a,b) #b"("a")" #define imm(a) "$"#a +#ifdef USE_UNDERSCORE +#define sym(a) "_"#a +#else #define sym(a) #a +#endif #define indx(a,b,c,d) #b"("a","c","#d")" #define indsx(a,s,b,c,d) s"+"#b"("a","c","#d")" @@ -76,13 +82,14 @@ static void orl (char *src, char *dst) { static void imull (unsigned long val, char *dst) { printf ("\timull $0x%08lx,%s\n", val, dst); } static void decl (char *dst) { printf ("\tdecl %s\n", dst); } static void incl (char *dst) { printf ("\tincl %s\n", dst); } -static void bswapl (char *dst) { printf ("\tbswapl %s\n", dst); } +static void bswapl (char *dst) { printf ("\tbswap %s\n", dst); } static void shrl (int count, char *dst) { printf ("\tshrl $%d,%s\n", count, dst); } static void shll (int count, char *dst) { printf ("\tshll $%d,%s\n", count, dst); } static void pushl (char *src) { printf ("\tpushl %s\n", src); } static void popl (char *dst) { printf ("\tpopl %s\n", dst); } static void ret (void) { printf ("\tret\n"); } -static void align (int a) { printf ("\t.align %d\n", 1 << a); } +static void align (int a) { printf ("\t.p2align %d,0x90\n", a); } + static void shiftleftl (int count, char *dst) { if (count == 0) @@ -109,7 +116,7 @@ static void shiftleftl (int count, char static void declare_fn (char *name) { printf ("\t.globl %s\n", name); - printf ("\t.type %s,@function\n", name); +/* printf ("\t.type %s,@function\n", name); */ align (5); printf ("%s:\n", name); } @@ -139,7 +146,7 @@ static void gen_x86_set_hires_h_toobad_k char buf[40]; char *indb0; - sprintf (buf, "set_hires_h_%d_%d", pl, mode); + sprintf (buf, sym (set_hires_h_%d_%d), pl, mode); declare_fn (buf); pushl (ebp); @@ -235,7 +242,7 @@ static void gen_x86_set_hires_h (int pl, char buf[40]; char *indb0; - sprintf (buf, "set_hires_h_%d_%d", pl, mode); + sprintf (buf, sym (set_hires_h_%d_%d), pl, mode); declare_fn (buf); pushl (ebp); @@ -353,7 +360,7 @@ static void gen_x86_set_hires_h (int pl, } break; } - + if (i < pl) { orl (esi, ecx); orl (ebp, ebx); @@ -381,7 +388,7 @@ static void gen_x86_set_hires_h (int pl, printf ("\n\n"); } -/* Squeeze: every second bit does not generate a pixel +/* Squeeze: every second bit does not generate a pixel Not optimized, this mode isn't useful. */ static void gen_x86_set_hires_l (int pl, int mode) { @@ -391,14 +398,14 @@ static void gen_x86_set_hires_l (int pl, int loop; char buf[40]; - sprintf (buf, "set_hires_l_%d_%d", pl, mode); + sprintf (buf, sym (set_hires_l_%d_%d), pl, mode); declare_fn (buf); pushl (ebp); pushl (esi); pushl (edi); pushl (ebx); - + movl (ind (esp, 20), ebp); movl (ind (esp, 24), esi); movl (imm (0), edi); @@ -450,14 +457,14 @@ static void gen_x86_set_lores_h (int pl, int loop; char buf[40]; - sprintf (buf, "set_lores_h_%d_%d", pl, mode); + sprintf (buf, sym (set_lores_h_%d_%d), pl, mode); declare_fn (buf); pushl (ebp); pushl (esi); pushl (edi); pushl (ebx); - + movl (ind (esp, 20), ebp); movl (ind (esp, 24), esi); movl (imm (0), edi); @@ -476,7 +483,7 @@ static void gen_x86_set_lores_h (int pl, char *data1 = (i == 0 && mode != 2 ? ecx : edx); char *data2 = (i == 0 && mode != 2 ? ebx : eax); char *indb0; - + indb0 = gen_indx (esi, realpl*MAX_WORDS_PER_LINE*2, edi, 1); movzbl (indb0, data2); free (indb0); @@ -535,10 +542,10 @@ static void gen_c_set_hires_h (int pl, i for (i = 0; i <= pl; i++) { int realpl = i * plmul + ploff; char *asgn = (i == 0 && mode != 2 ? "=" : "|="); - + printf ("\t\t{\n"); printf ("\t\t\tunsigned int data = *(ptr + i + %d);\n", MAX_WORDS_PER_LINE*2*realpl); - + printf ("\t\t\tv1 %s hirestab_h[data][0] << %d;\n", asgn, realpl); printf ("\t\t\tv2 %s hirestab_h[data][1] << %d;\n", asgn, realpl); printf ("\t\t}\n"); @@ -549,14 +556,13 @@ static void gen_c_set_hires_h (int pl, i printf ("}\n\n"); } -/* Squeeze: every second bit does not generate a pixel +/* Squeeze: every second bit does not generate a pixel Not optimized, this mode isn't useful. */ static void gen_c_set_hires_l (int pl, int mode, int header) { int plmul = mode == 0 ? 1 : 2; int ploff = mode == 2 ? 1 : 0; int i; - int loop; if (header) printf("extern "); @@ -575,7 +581,7 @@ static void gen_c_set_hires_l (int pl, i for (i = 0; i <= pl; i++) { int realpl = i * plmul + ploff; char *asgn = (i == 0 && mode != 2 ? "=" : "|="); - + printf ("\t\t{\n"); printf ("\t\t\tunsigned int data = *(ptr + i + %d);\n", MAX_WORDS_PER_LINE*2*realpl); @@ -592,7 +598,7 @@ static void gen_c_set_lores_h (int pl, i { int plmul = mode == 0 ? 1 : 2; int ploff = mode == 2 ? 1 : 0; - int i, j; + int i; if (header) printf("extern ");