2 Copyright © 1995-2019, The AROS Development Team. All rights reserved.
5 /* This program generates the p96call.h macroset for gcc-4.5.1 m68k-elf
7 * WARNING: The header generated by this program is designed
8 * to work with GCC 4.5.1 m68k-elf ONLY, and even
9 * then it has only been very lightly tested with
10 * "-O2 -fomit-frame-pointer -ffixed-a6"
12 * If it breaks, you get to keep both pieces.
17 #define GENCALL_MAX (13 + 1) /* Max number of arguments */
19 static void asm_regs_init(int id
, int has_bn
, const char *jmp
, const char *addr
)
24 for (i
= 0; i
< id
; i
++)
25 printf("\t ULONG _arg%d = (ULONG)__AROS_LCA(a%d); \\\n",
28 printf("\t ULONG _bn_arg = (ULONG)bn; \\\n");
30 /* Define registers */
31 printf("\t register volatile ULONG _ret asm(\"%%d0\"); \\\n");
32 for (i
= 0; i
< id
; i
++)
33 printf("\t register volatile ULONG __AROS_LTA(a%d) asm(__AROS_LSA(a%d)); \\\n",
36 printf("\t register volatile ULONG _bn asm(\"%%a6\"); \\\n");
39 /* Set registers (non FP) */
40 for (i
= 1; i
<= id
; i
++)
41 printf("\t if (! __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
42 "\t __AROS_LTA(a%d) = _arg%d; } \\\n",
45 printf("\t if (! __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
46 "\t _bn = _bn_arg; } \\\n");
49 for (i
= 1; i
<= id
; i
++) {
51 printf("\t if ( __AROS_ISREG(a%d,__AROS_FP_REG)) { \\\n"
52 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_arg%d), %s \\\n",
54 for (j
= 0; j
< id
; j
++)
55 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j
+ 1);
56 printf("\t ); }\\\n");
60 printf("\t if ( __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)) { \\\n"
61 "\t asm volatile (\"move.l %%%%\" __AROS_FP_SREG \",%%%%sp@-\\nmove.l %%0,%%%%\" __AROS_FP_SREG \"\\n%s\\nmove.l %%%%sp@+,%%%%\" __AROS_FP_SREG \"\\n\" : : \"r\" (_bn_arg), %s \\\n", jmp
, addr
);
62 for (j
= 0; j
< id
; j
++)
63 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j
+ 1);
64 printf("\t ); }\\\n");
66 if (has_bn
|| id
> 0) {
70 printf(" || __AROS_ISREG(bt,bn,A6,__AROS_FP_REG)");
71 for (i
= 0; i
< id
; i
++)
72 printf(" || __AROS_ISREG(a%d,__AROS_FP_REG)", i
+1);
74 "\t asm volatile (\"%s\\n\" : : \"i\" (0), %s \\\n", jmp
, addr
);
75 for (j
= 0; j
< id
; j
++)
76 printf("\t\t, \"r\" (__AROS_LTA(a%d)) \\\n", j
+ 1);
77 printf("\t ); }\\\n");
81 static void asm_regs_exit(int id
, int has_bn
)
83 /* Get the return code */
84 printf("\t asm volatile (\"\" : \"=r\" (_ret) : : \"%%a0\", \"%%a1\", \"%%d1\", \"cc\", \"memory\"); \\\n");
87 printf("\t (t)_ret; \\\n");
90 static void p96_lc(int id
)
95 printf("#define P96_LC%d(t,vector,id", id
);
96 for (i
= 0; i
< id
; i
++)
97 printf(",a%d", i
+ 1);
99 printf("\t({ APTR _n = (vector);\\\n");
100 snprintf(jmp
, sizeof(jmp
), "move.l %%3,%%%%sp@-\\n"
101 "pea.l .Lufc%d_%%c2\\n"
102 "move.l %%1, %%%%sp@-\\n"
105 "addq.l #4,%%%%sp\\n"
107 jmp
[sizeof(jmp
)-1]=0;
108 asm_regs_init(i
, 0, jmp
, "\"r\" (_n), \"i\" (__LINE__), \"i\" (id)");
114 int main(int argc
, char **argv
)
118 printf("/* AUTOGENERATED by p96call.c */\n");
119 printf("/* If you can get this to work for anything other */\n");
120 printf("/* than gcc-4.5.1 m68k-elf, it would be surprising. */\n");
122 printf("#ifndef P96CALL_H\n");
123 printf("#define P96CALL_H\n");
125 printf("/* Call a P96 function */\n");
128 for (i
= 0; i
< GENCALL_MAX
; i
++)
131 printf("#endif /* P96CALL_H */\n");