Wanderer/Info: fix compilation
[AROS.git] / arch / .unmaintained / m68k-emul / machine.h
blob26d766bd869dc126440e767afa834a6afa25cc3f
1 #ifndef AROS_MACHINE_H
2 #define AROS_MACHINE_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 NOTE: This file must compile *without* any other header !
10 Desc: machine.h include file for Linux/m68k (and others?)
11 Lang: english
14 /* We want register args, and LVOs */
15 #define UseRegisterArgs 1
16 #define EnableSetFunction 1
17 /*
18 We want full AmigaOS compatibility. When calling obtainsemaphore,
19 obtainsemaphoreshared, releasesemaphore, getcc, permit, forbid,
20 enable, disable and getcc *all* Registers need to be preserved.
21 But due to the gnu c-compiler we only have to preserve d0,d1,a0,a1.
22 UseExecstubs has to be defined when UseRegisterArgs is used!
24 #ifdef UseRegisterArgs
25 #define UseExecstubs
26 #endif
29 /* Linux/m68k gcc has no register args capabilities */
30 #define AROS_COMPILER_NO_REGARGS
32 /* Information generated by machine.c */
33 #define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
34 #define AROS_BIG_ENDIAN 1 /* Big or little endian */
35 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
36 #define AROS_WORDALIGN 2 /* Alignment for WORD */
37 #define AROS_LONGALIGN 2 /* Alignment for LONG */
38 #define AROS_PTRALIGN 2 /* Alignment for PTR */
39 #define AROS_IPTRALIGN 2 /* Alignment for IPTR */
40 #define AROS_DOUBLEALIGN 2 /* Alignment for double */
41 #define AROS_WORSTALIGN 8 /* Worst case alignment */
43 #define AROS_GET_SYSBASE extern struct ExecBase * SysBase;
44 #define AROS_GET_DOSBASE extern struct DosLibrary * DOSBase;
45 #define AROS_GET_SYSBASE_OK extern struct ExecBase * SysBase;
47 /* do we need a function attribute to get parameters on the stack? */
48 #define __stackparm
50 register unsigned char * AROS_GET_SP asm("%sp");
53 How much do I have to add to sp to get the address of the first
54 byte on the stack?
56 #define SP_OFFSET 0
59 Retain binary compatibility with AmigaOS.
60 Comment this out if you want APTRs.
62 #define AROS_BSTR_TYPE long
63 #define AROS_BPTR_TYPE long
64 #define MKBADDR(a) (((LONG)(a)) >> 2)
65 #define BADDR(a) ((APTR)((ULONG)(a) << 2))
68 One entry in a libraries' jumptable. For assembler compatibility, the
69 field jmp should contain the code for an absolute jmp to a 32bit
70 address. There are also a couple of macros which you should use to
71 access the vector table from C.
73 struct JumpVec
75 unsigned short jmp;
76 unsigned char vec[4];
79 /* Internal macros */
80 #define __AROS_ASMJMP 0x4EF9
81 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
83 #if UseRegisterArgs
84 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec)+2)
85 #else
86 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
87 #endif
89 /* Use these to acces a vector table */
90 #define LIB_VECTSIZE (sizeof (struct JumpVec))
91 #define __AROS_GETJUMPVEC(lib,n) ((struct JumpVec *)(((UBYTE *)lib)-(n*LIB_VECTSIZE)))
92 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
93 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
94 #define __AROS_INITVEC(lib,n) __AROS_GETJUMPVEC(lib,n)->jmp = __AROS_ASMJMP, \
95 __AROS_SETVECADDR(lib,n,_aros_not_implemented)
98 Find the next valid alignment for a structure if the next x bytes must
99 be skipped.
101 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
103 /* Prototypes */
104 extern void _aros_not_implemented (void);
106 /* How much stack do we need ? Lots :-) */
107 #define AROS_STACKSIZE 100000
110 /* How to map function arguments to CPU registers */
112 /* The registers */
113 #define D0 "%d0"
114 #define D1 "%d1"
115 #define D2 "%d2"
116 #define D3 "%d3"
117 #define D4 "%d4"
118 #define D5 "%d5"
119 #define D6 "%d6"
120 #define D7 "%d7"
121 #define A0 "%a0"
122 #define A1 "%a1"
123 #define A2 "%a2"
124 #define A3 "%a3"
125 #define A4 "%a4"
126 #define A5 "%a5"
127 #define A6 "%a6" /* This will only work with m68k-linux-gcc when
128 compiling with -O0 and -fomit-frame-pointer */
131 /* What to do with the library base in header, prototype and call */
132 #define __AROS_LH_BASE(basetype,basename) basetype basename
133 #define __AROS_LP_BASE(basetype,basename) void *
134 #define __AROS_LC_BASE(basetype,basename) basename
136 /* How to transform an argument in header, prototype and call */
137 #define __AROS_LHA(type,name,reg) type name
138 #define __AROS_LPA(type,name,reg) type
139 #define __AROS_LCA(type,name,reg) name
140 #define __AROS_UFHA(type,name,reg) type name
141 #define __AROS_UFPA(type,name,reg) type
142 #define __AROS_UFCA(type,name,reg) name
144 /* Prefix for library function in header, prototype and call */
145 #define __AROS_LH_PREFIX /* eps */
146 #define __AROS_LP_PREFIX /* eps */
147 #define __AROS_LC_PREFIX /* eps */
148 #define __AROS_UFH_PREFIX /* eps */
149 #define __AROS_UFP_PREFIX /* eps */
150 #define __AROS_UFC_PREFIX /* eps */
152 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
153 #define __AROS_USE_MACROS_FOR_LIBCALL
155 #if UseRegisterArgs
156 /* We need to redefine all the macros for use with Linux/m68k gcc */
158 #define AROS_SLIB_ENTRY_S(n,s) #s "_" #n
160 #define __ASM_PREFIX(name,system) \
161 __asm__(".text\n\t.balign 16\n\t"\
162 ".globl "## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
163 ".type "## AROS_SLIB_ENTRY_S(name,system) ##",@function\n"\
164 AROS_SLIB_ENTRY_S(name,system) ##":\n\t"\
165 "jbra .AmigaSWInit"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
166 "jbra _"## AROS_SLIB_ENTRY_S(name,system) ##"\n"\
167 ".AmigaSWInit"## AROS_SLIB_ENTRY_S(name,system) ##":\n\t"\
168 "move.l %a6,-(%sp)\n\t"
171 #define __ASM_PREFIXI(name,system) \
172 __asm__(".text\n\t.balign 16\n\t"\
173 ".globl "## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
174 ".type "## AROS_SLIB_ENTRY_S(name,system) ##",@function\n"\
175 AROS_SLIB_ENTRY_S(name,system) ##":\n\t"\
176 "jbra .AmigaSWInit"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
177 "jbra _"## AROS_SLIB_ENTRY_S(name,system) ##"\n"\
178 ".AmigaSWInit"## AROS_SLIB_ENTRY_S(name,system) ##":\n\t"\
182 #define __ASM_ARG(type, name, reg) \
183 "move.l "## reg ##",-(%sp)\n\t"
185 #define __ASM_POSTFIX(type,name,system,argc) \
186 "jsr _"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
187 "add.w #4*" #argc "+4,%sp\n\t"\
188 "rts\n\t"\
189 ".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
190 ## AROS_SLIB_ENTRY_S(name,system) );\
191 __AROS_LH_PREFIX type AROS_SLIB_ENTRY(name,_##system)(
194 #define __ASM_POSTFIXI(type,name,system,argc) \
195 "jsr _"## AROS_SLIB_ENTRY_S(name,system) ##"\n\t"\
196 "add.w #4*" #argc ",%sp\n\t"\
197 "rts\n\t"\
198 ".size "## AROS_SLIB_ENTRY_S(name,system) ##",.-"\
199 ## AROS_SLIB_ENTRY_S(name,system) );\
200 __AROS_LH_PREFIX type AROS_SLIB_ENTRY(name,_##system)(
203 #define AROS_LH0(t,n,bt,bn,o,s) \
204 __ASM_PREFIX(n,s)\
205 __ASM_POSTFIX(t,n,s,0)\
206 __AROS_LH_BASE(bt,bn))
208 #define AROS_LH1(t,n,a1,bt,bn,o,s) \
209 __ASM_PREFIX(n,s)\
210 __ASM_ARG(a1)\
211 __ASM_POSTFIX(t,n,s,1)\
212 __AROS_LHA(a1),\
213 __AROS_LH_BASE(bt,bn))
215 #define AROS_LH2(t,n,a1,a2,bt,bn,o,s) \
216 __ASM_PREFIX(n,s)\
217 __ASM_ARG(a2)\
218 __ASM_ARG(a1)\
219 __ASM_POSTFIX(t,n,s,2)\
220 __AROS_LHA(a1),\
221 __AROS_LHA(a2),\
222 __AROS_LH_BASE(bt,bn))
224 #define AROS_LH3(t,n,a1,a2,a3,bt,bn,o,s) \
225 __ASM_PREFIX(n,s)\
226 __ASM_ARG(a3)\
227 __ASM_ARG(a2)\
228 __ASM_ARG(a1)\
229 __ASM_POSTFIX(t,n,s,3)\
230 __AROS_LHA(a1),\
231 __AROS_LHA(a2),\
232 __AROS_LHA(a3),\
233 __AROS_LH_BASE(bt,bn))
235 #define AROS_LH4(t,n,a1,a2,a3,a4,bt,bn,o,s) \
236 __ASM_PREFIX(n,s)\
237 __ASM_ARG(a4)\
238 __ASM_ARG(a3)\
239 __ASM_ARG(a2)\
240 __ASM_ARG(a1)\
241 __ASM_POSTFIX(t,n,s,4)\
242 __AROS_LHA(a1),\
243 __AROS_LHA(a2),\
244 __AROS_LHA(a3),\
245 __AROS_LHA(a4),\
246 __AROS_LH_BASE(bt,bn))
248 #define AROS_LH5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) \
249 __ASM_PREFIX(n,s)\
250 __ASM_ARG(a5)\
251 __ASM_ARG(a4)\
252 __ASM_ARG(a3)\
253 __ASM_ARG(a2)\
254 __ASM_ARG(a1)\
255 __ASM_POSTFIX(t,n,s,5)\
256 __AROS_LHA(a1),\
257 __AROS_LHA(a2),\
258 __AROS_LHA(a3),\
259 __AROS_LHA(a4),\
260 __AROS_LHA(a5),\
261 __AROS_LH_BASE(bt,bn))
263 #define AROS_LH6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
264 __ASM_PREFIX(n,s)\
265 __ASM_ARG(a6)\
266 __ASM_ARG(a5)\
267 __ASM_ARG(a4)\
268 __ASM_ARG(a3)\
269 __ASM_ARG(a2)\
270 __ASM_ARG(a1)\
271 __ASM_POSTFIX(t,n,s,6)\
272 __AROS_LHA(a1),\
273 __AROS_LHA(a2),\
274 __AROS_LHA(a3),\
275 __AROS_LHA(a4),\
276 __AROS_LHA(a5),\
277 __AROS_LHA(a6),\
278 __AROS_LH_BASE(bt,bn))
280 #define AROS_LH7(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
281 __ASM_PREFIX(n,s)\
282 __ASM_ARG(a7)\
283 __ASM_ARG(a6)\
284 __ASM_ARG(a5)\
285 __ASM_ARG(a4)\
286 __ASM_ARG(a3)\
287 __ASM_ARG(a2)\
288 __ASM_ARG(a1)\
289 __ASM_POSTFIX(t,n,s,7)\
290 __AROS_LHA(a1),\
291 __AROS_LHA(a2),\
292 __AROS_LHA(a3),\
293 __AROS_LHA(a4),\
294 __AROS_LHA(a5),\
295 __AROS_LHA(a6),\
296 __AROS_LHA(a7),\
297 __AROS_LH_BASE(bt,bn))
299 #define AROS_LH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
300 __ASM_PREFIX(n,s)\
301 __ASM_ARG(a8)\
302 __ASM_ARG(a7)\
303 __ASM_ARG(a6)\
304 __ASM_ARG(a5)\
305 __ASM_ARG(a4)\
306 __ASM_ARG(a3)\
307 __ASM_ARG(a2)\
308 __ASM_ARG(a1)\
309 __ASM_POSTFIX(t,n,s,8)\
310 __AROS_LHA(a1),\
311 __AROS_LHA(a2),\
312 __AROS_LHA(a3),\
313 __AROS_LHA(a4),\
314 __AROS_LHA(a5),\
315 __AROS_LHA(a6),\
316 __AROS_LHA(a7),\
317 __AROS_LHA(a8),\
318 __AROS_LH_BASE(bt,bn))
320 #define AROS_LH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
321 __ASM_PREFIX(n,s)\
322 __ASM_ARG(a9)\
323 __ASM_ARG(a8)\
324 __ASM_ARG(a7)\
325 __ASM_ARG(a6)\
326 __ASM_ARG(a5)\
327 __ASM_ARG(a4)\
328 __ASM_ARG(a3)\
329 __ASM_ARG(a2)\
330 __ASM_ARG(a1)\
331 __ASM_POSTFIX(t,n,s,9)\
332 __AROS_LHA(a1),\
333 __AROS_LHA(a2),\
334 __AROS_LHA(a3),\
335 __AROS_LHA(a4),\
336 __AROS_LHA(a5),\
337 __AROS_LHA(a6),\
338 __AROS_LHA(a7),\
339 __AROS_LHA(a8),\
340 __AROS_LHA(a9),\
341 __AROS_LH_BASE(bt,bn))
343 #define AROS_LH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
344 __ASM_PREFIX(n,s)\
345 __ASM_ARG(a10)\
346 __ASM_ARG(a9)\
347 __ASM_ARG(a8)\
348 __ASM_ARG(a7)\
349 __ASM_ARG(a6)\
350 __ASM_ARG(a5)\
351 __ASM_ARG(a4)\
352 __ASM_ARG(a3)\
353 __ASM_ARG(a2)\
354 __ASM_ARG(a1)\
355 __ASM_POSTFIX(t,n,s,10)\
356 __AROS_LHA(a1),\
357 __AROS_LHA(a2),\
358 __AROS_LHA(a3),\
359 __AROS_LHA(a4),\
360 __AROS_LHA(a5),\
361 __AROS_LHA(a6),\
362 __AROS_LHA(a7),\
363 __AROS_LHA(a8),\
364 __AROS_LHA(a9),\
365 __AROS_LHA(a10),\
366 __AROS_LH_BASE(bt,bn))
368 #define AROS_LH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
369 __ASM_PREFIX(n,s)\
370 __ASM_ARG(a11)\
371 __ASM_ARG(a10)\
372 __ASM_ARG(a9)\
373 __ASM_ARG(a8)\
374 __ASM_ARG(a7)\
375 __ASM_ARG(a6)\
376 __ASM_ARG(a5)\
377 __ASM_ARG(a4)\
378 __ASM_ARG(a3)\
379 __ASM_ARG(a2)\
380 __ASM_ARG(a1)\
381 __ASM_POSTFIX(t,n,s,11)\
382 __AROS_LHA(a1),\
383 __AROS_LHA(a2),\
384 __AROS_LHA(a3),\
385 __AROS_LHA(a4),\
386 __AROS_LHA(a5),\
387 __AROS_LHA(a6),\
388 __AROS_LHA(a7),\
389 __AROS_LHA(a8),\
390 __AROS_LHA(a9),\
391 __AROS_LHA(a10),\
392 __AROS_LHA(a11),\
393 __AROS_LH_BASE(bt,bn))
395 #define AROS_LH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,bt,bn,o,s) \
396 __ASM_PREFIX(n,s)\
397 __ASM_ARG(a12)\
398 __ASM_ARG(a11)\
399 __ASM_ARG(a10)\
400 __ASM_ARG(a9)\
401 __ASM_ARG(a8)\
402 __ASM_ARG(a7)\
403 __ASM_ARG(a6)\
404 __ASM_ARG(a5)\
405 __ASM_ARG(a4)\
406 __ASM_ARG(a3)\
407 __ASM_ARG(a2)\
408 __ASM_ARG(a1)\
409 __ASM_POSTFIX(t,n,s,12)\
410 __AROS_LHA(a1),\
411 __AROS_LHA(a2),\
412 __AROS_LHA(a3),\
413 __AROS_LHA(a4),\
414 __AROS_LHA(a5),\
415 __AROS_LHA(a6),\
416 __AROS_LHA(a7),\
417 __AROS_LHA(a8),\
418 __AROS_LHA(a9),\
419 __AROS_LHA(a10),\
420 __AROS_LHA(a11),\
421 __AROS_LHA(a12),\
422 __AROS_LH_BASE(bt,bn))
424 #define AROS_LH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,bt,bn,o,s) \
425 __ASM_PREFIX(n,s)\
426 __ASM_ARG(a13)\
427 __ASM_ARG(a12)\
428 __ASM_ARG(a11)\
429 __ASM_ARG(a10)\
430 __ASM_ARG(a9)\
431 __ASM_ARG(a8)\
432 __ASM_ARG(a7)\
433 __ASM_ARG(a6)\
434 __ASM_ARG(a5)\
435 __ASM_ARG(a4)\
436 __ASM_ARG(a3)\
437 __ASM_ARG(a2)\
438 __ASM_ARG(a1)\
439 __ASM_POSTFIX(t,n,s,13)\
440 __AROS_LHA(a1),\
441 __AROS_LHA(a2),\
442 __AROS_LHA(a3),\
443 __AROS_LHA(a4),\
444 __AROS_LHA(a5),\
445 __AROS_LHA(a6),\
446 __AROS_LHA(a7),\
447 __AROS_LHA(a8),\
448 __AROS_LHA(a9),\
449 __AROS_LHA(a10),\
450 __AROS_LHA(a11),\
451 __AROS_LHA(a12),\
452 __AROS_LHA(a13),\
453 __AROS_LH_BASE(bt,bn))
455 #define AROS_LH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,bt,bn,o,s) \
456 __ASM_PREFIX(n,s)\
457 __ASM_ARG(a14)\
458 __ASM_ARG(a13)\
459 __ASM_ARG(a12)\
460 __ASM_ARG(a11)\
461 __ASM_ARG(a10)\
462 __ASM_ARG(a9)\
463 __ASM_ARG(a8)\
464 __ASM_ARG(a7)\
465 __ASM_ARG(a6)\
466 __ASM_ARG(a5)\
467 __ASM_ARG(a4)\
468 __ASM_ARG(a3)\
469 __ASM_ARG(a2)\
470 __ASM_ARG(a1)\
471 __ASM_POSTFIX(t,n,s,14)\
472 __AROS_LHA(a1),\
473 __AROS_LHA(a2),\
474 __AROS_LHA(a3),\
475 __AROS_LHA(a4),\
476 __AROS_LHA(a5),\
477 __AROS_LHA(a6),\
478 __AROS_LHA(a7),\
479 __AROS_LHA(a8),\
480 __AROS_LHA(a9),\
481 __AROS_LHA(a10),\
482 __AROS_LHA(a11),\
483 __AROS_LHA(a12),\
484 __AROS_LHA(a13),\
485 __AROS_LHA(a14),\
486 __AROS_LH_BASE(bt,bn))
488 #define AROS_LH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,bt,bn,o,s) \
489 __ASM_PREFIX(n,s)\
490 __ASM_ARG(a15)\
491 __ASM_ARG(a14)\
492 __ASM_ARG(a13)\
493 __ASM_ARG(a12)\
494 __ASM_ARG(a11)\
495 __ASM_ARG(a10)\
496 __ASM_ARG(a9)\
497 __ASM_ARG(a8)\
498 __ASM_ARG(a7)\
499 __ASM_ARG(a6)\
500 __ASM_ARG(a5)\
501 __ASM_ARG(a4)\
502 __ASM_ARG(a3)\
503 __ASM_ARG(a2)\
504 __ASM_ARG(a1)\
505 __ASM_POSTFIX(t,n,s,15)\
506 __AROS_LHA(a1),\
507 __AROS_LHA(a2),\
508 __AROS_LHA(a3),\
509 __AROS_LHA(a4),\
510 __AROS_LHA(a5),\
511 __AROS_LHA(a6),\
512 __AROS_LHA(a7),\
513 __AROS_LHA(a8),\
514 __AROS_LHA(a9),\
515 __AROS_LHA(a10),\
516 __AROS_LHA(a11),\
517 __AROS_LHA(a12),\
518 __AROS_LHA(a13),\
519 __AROS_LHA(a14),\
520 __AROS_LHA(a15),\
521 __AROS_LH_BASE(bt,bn))
523 /* Library functions which don't need the libbase */
524 #define AROS_LH0I(t,n,bt,bn,o,s) \
525 __AROS_LH_PREFIX t AROS_SLIB_ENTRY(n,s)(void)
527 #define AROS_LH1I(t,n,a1,bt,bn,o,s) \
528 __ASM_PREFIXI(n,s)\
529 __ASM_ARG(a1)\
530 __ASM_POSTFIXI(t,n,s,1)\
531 __AROS_LHA(a1))
533 #define AROS_LH2I(t,n,a1,a2,bt,bn,o,s) \
534 __ASM_PREFIXI(n,s)\
535 __ASM_ARG(a2)\
536 __ASM_ARG(a1)\
537 __ASM_POSTFIXI(t,n,s,2)\
538 __AROS_LHA(a1),\
539 __AROS_LHA(a2))
541 #define AROS_LH3I(t,n,a1,a2,a3,bt,bn,o,s) \
542 __ASM_PREFIXI(n,s)\
543 __ASM_ARG(a3)\
544 __ASM_ARG(a2)\
545 __ASM_ARG(a1)\
546 __ASM_POSTFIXI(t,n,s,3)\
547 __AROS_LHA(a1),\
548 __AROS_LHA(a2),\
549 __AROS_LHA(a3))
551 #define AROS_LH4I(t,n,a1,a2,a3,a4,bt,bn,o,s) \
552 __ASM_PREFIXI(n,s)\
553 __ASM_ARG(a4)\
554 __ASM_ARG(a3)\
555 __ASM_ARG(a2)\
556 __ASM_ARG(a1)\
557 __ASM_POSTFIXI(t,n,s,4)\
558 __AROS_LHA(a1),\
559 __AROS_LHA(a2),\
560 __AROS_LHA(a3),\
561 __AROS_LHA(a4))
563 #define AROS_LH5I(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) \
564 __ASM_PREFIXI(n,s)\
565 __ASM_ARG(a5)\
566 __ASM_ARG(a4)\
567 __ASM_ARG(a3)\
568 __ASM_ARG(a2)\
569 __ASM_ARG(a1)\
570 __ASM_POSTFIXI(t,n,s,5)\
571 __AROS_LHA(a1),\
572 __AROS_LHA(a2),\
573 __AROS_LHA(a3),\
574 __AROS_LHA(a4),\
575 __AROS_LHA(a5))
577 #define AROS_LH6I(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
578 __ASM_PREFIXI(n,s)\
579 __ASM_ARG(a6)\
580 __ASM_ARG(a5)\
581 __ASM_ARG(a4)\
582 __ASM_ARG(a3)\
583 __ASM_ARG(a2)\
584 __ASM_ARG(a1)\
585 __ASM_POSTFIXI(t,n,s,6)\
586 __AROS_LHA(a1),\
587 __AROS_LHA(a2),\
588 __AROS_LHA(a3),\
589 __AROS_LHA(a4),\
590 __AROS_LHA(a5),\
591 __AROS_LHA(a6))
593 #define AROS_LH7I(t,n,a1,a2,a3,a4,a5,a6,a7,bt,bn,o,s) \
594 __ASM_PREFIXI(n,s)\
595 __ASM_ARG(a7)\
596 __ASM_ARG(a6)\
597 __ASM_ARG(a5)\
598 __ASM_ARG(a4)\
599 __ASM_ARG(a3)\
600 __ASM_ARG(a2)\
601 __ASM_ARG(a1)\
602 __ASM_POSTFIXI(t,n,s,7)\
603 __AROS_LHA(a1),\
604 __AROS_LHA(a2),\
605 __AROS_LHA(a3),\
606 __AROS_LHA(a4),\
607 __AROS_LHA(a5),\
608 __AROS_LHA(a6),\
609 __AROS_LHA(a7))
611 #define AROS_LH8I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
612 __ASM_PREFIXI(n,s)\
613 __ASM_ARG(a8)\
614 __ASM_ARG(a7)\
615 __ASM_ARG(a6)\
616 __ASM_ARG(a5)\
617 __ASM_ARG(a4)\
618 __ASM_ARG(a3)\
619 __ASM_ARG(a2)\
620 __ASM_ARG(a1)\
621 __ASM_POSTFIXI(t,n,s,8)\
622 __AROS_LHA(a1),\
623 __AROS_LHA(a2),\
624 __AROS_LHA(a3),\
625 __AROS_LHA(a4),\
626 __AROS_LHA(a5),\
627 __AROS_LHA(a6),\
628 __AROS_LHA(a7),\
629 __AROS_LHA(a8))
631 #define AROS_LH9I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
632 __ASM_PREFIXI(n,s)\
633 __ASM_ARG(a9)\
634 __ASM_ARG(a8)\
635 __ASM_ARG(a7)\
636 __ASM_ARG(a6)\
637 __ASM_ARG(a5)\
638 __ASM_ARG(a4)\
639 __ASM_ARG(a3)\
640 __ASM_ARG(a2)\
641 __ASM_ARG(a1)\
642 __ASM_POSTFIXI(t,n,s,9)\
643 __AROS_LHA(a1),\
644 __AROS_LHA(a2),\
645 __AROS_LHA(a3),\
646 __AROS_LHA(a4),\
647 __AROS_LHA(a5),\
648 __AROS_LHA(a6),\
649 __AROS_LHA(a7),\
650 __AROS_LHA(a8),\
651 __AROS_LHA(a9))
653 #define AROS_LH10I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,bt,bn,o,s) \
654 __ASM_PREFIXI(n,s)\
655 __ASM_ARG(a10)\
656 __ASM_ARG(a9)\
657 __ASM_ARG(a8)\
658 __ASM_ARG(a7)\
659 __ASM_ARG(a6)\
660 __ASM_ARG(a5)\
661 __ASM_ARG(a4)\
662 __ASM_ARG(a3)\
663 __ASM_ARG(a2)\
664 __ASM_ARG(a1)\
665 __ASM_POSTFIXI(t,n,s,10)\
666 __AROS_LHA(a1),\
667 __AROS_LHA(a2),\
668 __AROS_LHA(a3),\
669 __AROS_LHA(a4),\
670 __AROS_LHA(a5),\
671 __AROS_LHA(a6),\
672 __AROS_LHA(a7),\
673 __AROS_LHA(a8),\
674 __AROS_LHA(a9),\
675 __AROS_LHA(a10))
677 #define AROS_LH11I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,bt,bn,o,s) \
678 __ASM_PREFIXI(n,s)\
679 __ASM_ARG(a11)\
680 __ASM_ARG(a10)\
681 __ASM_ARG(a9)\
682 __ASM_ARG(a8)\
683 __ASM_ARG(a7)\
684 __ASM_ARG(a6)\
685 __ASM_ARG(a5)\
686 __ASM_ARG(a4)\
687 __ASM_ARG(a3)\
688 __ASM_ARG(a2)\
689 __ASM_ARG(a1)\
690 __ASM_POSTFIXI(t,n,s,11)\
691 __AROS_LHA(a1),\
692 __AROS_LHA(a2),\
693 __AROS_LHA(a3),\
694 __AROS_LHA(a4),\
695 __AROS_LHA(a5),\
696 __AROS_LHA(a6),\
697 __AROS_LHA(a7),\
698 __AROS_LHA(a8),\
699 __AROS_LHA(a9),\
700 __AROS_LHA(a10),\
701 __AROS_LHA(a11))
703 #define AROS_LH12I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,bt,bn,o,s) \
704 __ASM_PREFIXI(n,s)\
705 __ASM_ARG(a12)\
706 __ASM_ARG(a11)\
707 __ASM_ARG(a10)\
708 __ASM_ARG(a9)\
709 __ASM_ARG(a8)\
710 __ASM_ARG(a7)\
711 __ASM_ARG(a6)\
712 __ASM_ARG(a5)\
713 __ASM_ARG(a4)\
714 __ASM_ARG(a3)\
715 __ASM_ARG(a2)\
716 __ASM_ARG(a1)\
717 __ASM_POSTFIXI(t,n,s,12)\
718 __AROS_LHA(a1),\
719 __AROS_LHA(a2),\
720 __AROS_LHA(a3),\
721 __AROS_LHA(a4),\
722 __AROS_LHA(a5),\
723 __AROS_LHA(a6),\
724 __AROS_LHA(a7),\
725 __AROS_LHA(a8),\
726 __AROS_LHA(a9),\
727 __AROS_LHA(a10),\
728 __AROS_LHA(a11),\
729 __AROS_LHA(a12))
731 #define AROS_LH13I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,bt,bn,o,s) \
732 __ASM_PREFIXI(n,s)\
733 __ASM_ARG(a13)\
734 __ASM_ARG(a12)\
735 __ASM_ARG(a11)\
736 __ASM_ARG(a10)\
737 __ASM_ARG(a9)\
738 __ASM_ARG(a8)\
739 __ASM_ARG(a7)\
740 __ASM_ARG(a6)\
741 __ASM_ARG(a5)\
742 __ASM_ARG(a4)\
743 __ASM_ARG(a3)\
744 __ASM_ARG(a2)\
745 __ASM_ARG(a1)\
746 __ASM_POSTFIXI(t,n,s,13)\
747 __AROS_LHA(a1),\
748 __AROS_LHA(a2),\
749 __AROS_LHA(a3),\
750 __AROS_LHA(a4),\
751 __AROS_LHA(a5),\
752 __AROS_LHA(a6),\
753 __AROS_LHA(a7),\
754 __AROS_LHA(a8),\
755 __AROS_LHA(a9),\
756 __AROS_LHA(a10),\
757 __AROS_LHA(a11),\
758 __AROS_LHA(a12),\
759 __AROS_LHA(a13))
761 #define AROS_LH14I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,bt,bn,o,s) \
762 __ASM_PREFIXI(n,s)\
763 __ASM_ARG(a14)\
764 __ASM_ARG(a13)\
765 __ASM_ARG(a12)\
766 __ASM_ARG(a11)\
767 __ASM_ARG(a10)\
768 __ASM_ARG(a9)\
769 __ASM_ARG(a8)\
770 __ASM_ARG(a7)\
771 __ASM_ARG(a6)\
772 __ASM_ARG(a5)\
773 __ASM_ARG(a4)\
774 __ASM_ARG(a3)\
775 __ASM_ARG(a2)\
776 __ASM_ARG(a1)\
777 __ASM_POSTFIXI(t,n,s,14)\
778 __AROS_LHA(a1),\
779 __AROS_LHA(a2),\
780 __AROS_LHA(a3),\
781 __AROS_LHA(a4),\
782 __AROS_LHA(a5),\
783 __AROS_LHA(a6),\
784 __AROS_LHA(a7),\
785 __AROS_LHA(a8),\
786 __AROS_LHA(a9),\
787 __AROS_LHA(a10),\
788 __AROS_LHA(a11),\
789 __AROS_LHA(a12),\
790 __AROS_LHA(a13),\
791 __AROS_LHA(a14))
793 #define AROS_LH15I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,bt,bn,o,s) \
794 __ASM_PREFIXI(n,s)\
795 __ASM_ARG(a15)\
796 __ASM_ARG(a14)\
797 __ASM_ARG(a13)\
798 __ASM_ARG(a12)\
799 __ASM_ARG(a11)\
800 __ASM_ARG(a10)\
801 __ASM_ARG(a9)\
802 __ASM_ARG(a8)\
803 __ASM_ARG(a7)\
804 __ASM_ARG(a6)\
805 __ASM_ARG(a5)\
806 __ASM_ARG(a4)\
807 __ASM_ARG(a3)\
808 __ASM_ARG(a2)\
809 __ASM_ARG(a1)\
810 __ASM_POSTFIXI(t,n,s,15)\
811 __AROS_LHA(a1),\
812 __AROS_LHA(a2),\
813 __AROS_LHA(a3),\
814 __AROS_LHA(a4),\
815 __AROS_LHA(a5),\
816 __AROS_LHA(a6),\
817 __AROS_LHA(a7),\
818 __AROS_LHA(a8),\
819 __AROS_LHA(a9),\
820 __AROS_LHA(a10),\
821 __AROS_LHA(a11),\
822 __AROS_LHA(a12),\
823 __AROS_LHA(a13),\
824 __AROS_LHA(a14),\
825 __AROS_LHA(a15))
828 This stuff does NOT work, but I leave it there anyway.
830 Taken from an old version of AROS:
831 This is one way to call a function with registerized parameters and gcc:
832 I build a define that defines normal function calls into one of those
833 LC0()-Makros for expansion directly into the source code.
835 They work as follows:
836 First I copy the arguments of the function into normal variables.
837 Second I copy those variables into the appropriate registers.
838 (I cannot write them directly into those registers because this locks
839 the register and one of the arguments may be a function call that needs it.)
840 Third I call the assembler function with registers as arguments.
841 Fourth I return the result. (The casting of the long is necessary to make
842 void work).
844 Prototype stylish Macros are also possible (using __inline functions instead
845 of defines) but they need more system ressources to compile, more complicated
846 Makefiles (gcc cannot inline without optimization) and cannot use local
847 library bases.
850 /****************************************************
851 #define __LC0(type,name,basetype,basename,offset,system) \
852 ({ \
854 register long __d0 __asm(D0); \
855 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
856 "move.l %1,%%a6\n\t" \
857 "jsr %%a6@(-6*"#offset":W)\n\t" \
858 "move.l (%%sp)+,%%a6" \
859 :"=r"(__d0) \
860 :"r"(basename) \
861 :D0,D1,A0,A1,"memory","cc"); \
862 (type)__d0; \
866 #define __LC1(t,n,t1,n1,r1,bt,bn,o,s) \
867 ({ \
868 t1 __n1 = (n1); \
870 register long __d0 __asm(D0); \
871 register long ___n1 __asm(r1) = (long)__n1; \
872 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
873 "move.l %2,%%a6\n\t" \
874 "jsr %%a6@(-6*"#o":W)\n\t" \
875 "move.l (%%sp)+,%%a6" \
876 :"=r"(__d0) \
877 :"r"(___n1),"r"(bn) \
878 :A0,A1,D0,D1,"memory","cc"); \
879 (t)__d0; \
883 #define __LC2(t,n,t1,n1,r1,t2,n2,r2,bt,bn,o,s) \
884 ({ \
885 t1 __n1 = (n1); \
886 t2 __n2 = (n2); \
888 register long __d0 __asm(D0); \
889 register long ___n1 __asm(r1) = (long)__n1; \
890 register long ___n2 __asm(r2) = (long)__n2; \
891 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
892 "move.l %1,%%a6\n\t" \
893 "jsr %%a6@(-6*"#o":W)\n\t" \
894 "move.l (%%sp)+,%%a6" \
895 :"=r"(__d0) \
896 :"r"(bn),"r"(___n1),"r"(___n2) \
897 :D0,D1,A0,A1,"memory","cc"); \
898 (t)__d0; \
902 #define __LC3(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,bt,bn,o,s) \
903 ({ \
904 t1 __n1 = (n1); \
905 t2 __n2 = (n2); \
906 t3 __n3 = (n3); \
908 register long __d0 __asm(D0); \
909 register long ___n1 __asm(r1) = (long)__n1; \
910 register long ___n2 __asm(r2) = (long)__n2; \
911 register long ___n3 __asm(r3) = (long)__n3; \
912 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
913 "move.l %4,%%a6\n\t" \
914 "jsr %%a6@(-6*"#o":W)\n\t" \
915 "move.l (%%sp)+,%%a6" \
916 :"=r"(__d0) \
917 :"r"(___n1),"r"(___n2),"r"(___n3), \
918 "r"(bn) \
919 :A0,A1,D0,D1,"memory","cc"); \
920 (t)__d0; \
924 #define __LC4(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,bt,bn,o,s) \
925 ({ \
926 t1 __n1 = (n1); \
927 t2 __n2 = (n2); \
928 t3 __n3 = (n3); \
929 t4 __n4 = (n4); \
931 register long __d0 __asm(D0); \
932 register long ___n1 __asm(r1) = (long)__n1; \
933 register long ___n2 __asm(r2) = (long)__n2; \
934 register long ___n3 __asm(r3) = (long)__n3; \
935 register long ___n4 __asm(r4) = (long)__n4; \
936 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
937 "move.l %5,%%a6\n\t" \
938 "jsr %%a6@(-6*"#o":W)\n\t" \
939 "move.l (%%sp)+,%%a6" \
940 :"=r"(__d0) \
941 :"r"(___n1),"r"(___n2),"r"(___n3), \
942 "r"(___n4),"r"(bn) \
943 :A0,A1,D0,D1,"memory","cc"); \
944 (t)__d0; \
948 #define __LC5(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,bt,bn,o,s) \
949 ({ \
950 t1 __n1 = (n1); \
951 t2 __n2 = (n2); \
952 t3 __n3 = (n3); \
953 t4 __n4 = (n4); \
954 t5 __n5 = (n5); \
956 register long __d0 __asm(D0); \
957 register long ___n1 __asm(r1) = (long)__n1; \
958 register long ___n2 __asm(r2) = (long)__n2; \
959 register long ___n3 __asm(r3) = (long)__n3; \
960 register long ___n4 __asm(r4) = (long)__n4; \
961 register long ___n5 __asm(r5) = (long)__n5; \
962 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
963 "move.l %6,%%a6\n\t" \
964 "jsr %%a6@(-6*"#o":W)\n\t" \
965 "move.l (%%sp)+,%%a6" \
966 :"=r"(__d0) \
967 :"r"(___n1),"r"(___n2),"r"(___n3), \
968 "r"(___n4),"r"(___n5),"r"(bn) \
969 :A0,A1,D0,D1,"memory","cc"); \
970 (t)__d0; \
974 #define __LC6(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,bt,bn,o,s) \
975 ({ \
976 t1 __n1 = (n1); \
977 t2 __n2 = (n2); \
978 t3 __n3 = (n3); \
979 t4 __n4 = (n4); \
980 t5 __n5 = (n5); \
981 t6 __n6 = (n6); \
983 register long __d0 __asm(D0); \
984 register long ___n1 __asm(r1) = (long)__n1; \
985 register long ___n2 __asm(r2) = (long)__n2; \
986 register long ___n3 __asm(r3) = (long)__n3; \
987 register long ___n4 __asm(r4) = (long)__n4; \
988 register long ___n5 __asm(r5) = (long)__n5; \
989 register long ___n6 __asm(r6) = (long)__n6; \
990 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
991 "move.l %7,%%a6\n\t" \
992 "jsr %%a6@(-6*"#o":W)\n\t" \
993 "move.l (%%sp)+,%%a6" \
994 :"=r"(__d0) \
995 :"r"(___n1),"r"(___n2),"r"(___n3), \
996 "r"(___n4),"r"(___n5),"r"(___n6), \
997 "r"(bn) \
998 :A0,A1,D0,D1,"memory","cc"); \
999 (t)__d0; \
1003 #define __LC9(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5,t6,n6,r6,t7,n7,r7,t8,n8,r8,t9,n9,r9,bt,bn,o,s) \
1004 ({ \
1005 t1 __n1 = (n1); \
1006 t2 __n2 = (n2); \
1007 t3 __n3 = (n3); \
1008 t4 __n4 = (n4); \
1009 t5 __n5 = (n5); \
1010 t6 __n6 = (n6); \
1011 t7 __n7 = (n7); \
1012 t8 __n8 = (n8); \
1013 t9 __n9 = (n9); \
1015 register long __d0 __asm(D0); \
1016 register long ___n1 __asm(r1) = (long)__n1; \
1017 register long ___n2 __asm(r2) = (long)__n2; \
1018 register long ___n3 __asm(r3) = (long)__n3; \
1019 register long ___n4 __asm(r4) = (long)__n4; \
1020 register long ___n5 __asm(r5) = (long)__n5; \
1021 register long ___n6 __asm(r6) = (long)__n6; \
1022 register long ___n7 __asm(r7) = (long)__n7; \
1023 register long ___n8 __asm(r8) = (long)__n8; \
1024 register long ___n9 __asm(r9) = (long)__n9; \
1025 __asm __volatile("move.l %%a6,-(%%sp)\n\t" \
1026 "move.l %9,%%a6\n\t" \
1027 "jsr %%a6@(-6*"#o":W)\n\t" \
1028 "move.l (%%sp)+,%%a6" \
1029 : / no output / \
1030 :"r"(___n1),"r"(___n2),"r"(___n3), \
1031 "r"(___n4),"r"(___n5),"r"(___n6), \
1032 "r"(___n7),"r"(___n8),"r"(___n9), \
1033 "r"(bn) \
1034 :A0,A1,D0,D1,"memory","cc"); \
1035 (t)__d0; \
1038 ****************************************************/
1040 /****************************************************
1041 #define AROS_LC0(t,n,bt,bn,o,s) __LC0(t,n,bt,bn,o,s)
1042 #define AROS_LC0I(t,n,bt,bn,o,s) __LC0(t,n,bt,bn,o,s)
1043 #define AROS_LC1(t,n,a1,bt,bn,o,s) __LC1(t,n,a1,bt,bn,o,s)
1044 #define AROS_LC1I(t,n,a1,bt,bn,o,s) __LC1(t,n,a1,bt,bn,o,s)
1045 #define AROS_LC2(t,n,a1,a2,bt,bn,o,s) __LC2(t,n,a1,a2,bt,bn,o,s)
1046 #define AROS_LC2I(t,n,a1,a2,bt,bn,o,s) __LC2(t,n,a1,a2,bt,bn,o,s)
1047 #define AROS_LC3(t,n,a1,a2,a3,bt,bn,o,s) __LC3(t,n,a1,a2,a3,bt,bn,o,s)
1048 #define AROS_LC3I(t,n,a1,a2,a3,bt,bn,o,s) __LC3(t,n,a1,a2,a3,bt,bn,o,s)
1049 #define AROS_LC4(t,n,a1,a2,a3,a4,bt,bn,o,s) __LC4(t,n,a1,a2,a3,a4,bt,bn,o,s)
1050 #define AROS_LC4I(t,n,a1,a2,a3,a4,bt,bn,o,s) __LC4(t,n,a1,a2,a3,a4,bt,bn,o,s)
1051 #define AROS_LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) __LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s)
1052 #define AROS_LC5I(t,n,a1,a2,a3,a4,a5,bt,bn,o,s) __LC5(t,n,a1,a2,a3,a4,a5,bt,bn,o,s)
1053 #define AROS_LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
1054 __LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s)
1055 #define AROS_LC6I(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s) \
1056 __LC6(t,n,a1,a2,a3,a4,a5,a6,bt,bn,o,s)
1057 #define AROS_LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
1058 __LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s)
1059 #define AROS_LC8I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s) \
1060 __LC8(t,n,a1,a2,a3,a4,a5,a6,a7,a8,bt,bn,o,s)
1061 #define AROS_LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
1062 __LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s)
1063 #define AROS_LC9I(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s) \
1064 __LC9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,bt,bn,o,s)
1066 #define AROS_LVO_CALL0(returntype,basetype,basename,offset,system) \
1067 __LC0(returntype,,basetype,basename,offset,system)
1069 #define AROS_LVO_CALL1(t,a1,bt,bn,o,s) \
1070 __LC1(t,,a1,bt,bn,o,s)
1072 #define AROS_LVO_CALL1NR(a1,bt,bn,o,s) \
1073 __LC1(void,,a1,bt,bn,o,s)
1075 #define AROS_LVO_CALL2(t,a1,a2,bt,bn,o,s) \
1076 __LC2(t,,a1,a2,bt,bn,o,s)
1078 #define AROS_LVO_CALL3(t,a1,a2,a3,bt,bn,o,s) \
1079 __LC3(t,,a1,a2,a3,bt,bn,o,s)
1081 #define AROS_LVO_CALL3NR(a1,a2,a3,bt,bn,o,s) \
1082 __LC3(void,,a1,a2,a3,bt,bn,o,s)
1084 #define AROS_LVO_CALL4(t,a1,a2,a3,a4,bt,bn,o,s) \
1085 __LC4(t,,a1,a2,a3,a4,bt,bn,o,s)
1087 *****************************************************************/
1091 /* Macros for user functions */
1093 #define __ASM_PREFIX_U(name) \
1094 __asm__(".text\n\t.balign 16\n"\
1095 ".globl " #name "\n\t"\
1096 ".type " #name ",@function\n"\
1097 #name ":\n\t"\
1099 #define __ASM_POSTFIX_U(type,name,argc) \
1100 "jsr _" #name "\n\t"\
1101 "add.w #4*" #argc ",%sp\n\t"\
1102 "rts\n\t"\
1103 ".size " #name ",.-" #name);\
1104 __AROS_UFH_PREFIX type _##name (
1107 /* Function headers for user functions */
1109 #define AROS_UFH0(t,n) \
1110 t n (void)
1112 #define AROS_UFH1(t,n,a1) \
1113 t n ();\
1114 __ASM_PREFIX_U(n)\
1115 __ASM_ARG(a1)\
1116 __ASM_POSTFIX_U(t,n,1)\
1117 __AROS_UFHA(a1))
1119 #define AROS_UFH2(t,n,a1,a2) \
1120 t n ();\
1121 __ASM_PREFIX_U(n)\
1122 __ASM_ARG(a2)\
1123 __ASM_ARG(a1)\
1124 __ASM_POSTFIX_U(t,n,2)\
1125 __AROS_UFHA(a1),\
1126 __AROS_UFHA(a2))
1128 #define AROS_UFH3(t,n,a1,a2,a3) \
1129 t n ();\
1130 __ASM_PREFIX_U(n)\
1131 __ASM_ARG(a3)\
1132 __ASM_ARG(a2)\
1133 __ASM_ARG(a1)\
1134 __ASM_POSTFIX_U(t,n,3)\
1135 __AROS_UFHA(a1),\
1136 __AROS_UFHA(a2),\
1137 __AROS_UFHA(a3))
1139 #define AROS_UFH4(t,n,a1,a2,a3,a4) \
1140 t n ();\
1141 __ASM_PREFIX_U(n)\
1142 __ASM_ARG(a4)\
1143 __ASM_ARG(a3)\
1144 __ASM_ARG(a2)\
1145 __ASM_ARG(a1)\
1146 __ASM_POSTFIX_U(t,n,4)\
1147 __AROS_UFHA(a1),\
1148 __AROS_UFHA(a2),\
1149 __AROS_UFHA(a3),\
1150 __AROS_UFHA(a4))
1152 #define AROS_UFH5(t,n,a1,a2,a3,a4,a5) \
1153 t n ();\
1154 __ASM_PREFIX_U(n)\
1155 __ASM_ARG(a5)\
1156 __ASM_ARG(a4)\
1157 __ASM_ARG(a3)\
1158 __ASM_ARG(a2)\
1159 __ASM_ARG(a1)\
1160 __ASM_POSTFIX_U(t,n,5)\
1161 __AROS_UFHA(a1),\
1162 __AROS_UFHA(a2),\
1163 __AROS_UFHA(a3),\
1164 __AROS_UFHA(a4),\
1165 __AROS_UFHA(a5))
1167 #define AROS_UFH6(t,n,a1,a2,a3,a4,a5,a6) \
1168 t n ();\
1169 __ASM_PREFIX_U(n)\
1170 __ASM_ARG(a6)\
1171 __ASM_ARG(a5)\
1172 __ASM_ARG(a4)\
1173 __ASM_ARG(a3)\
1174 __ASM_ARG(a2)\
1175 __ASM_ARG(a1)\
1176 __ASM_POSTFIX_U(t,n,6)\
1177 __AROS_UFHA(a1),\
1178 __AROS_UFHA(a2),\
1179 __AROS_UFHA(a3),\
1180 __AROS_UFHA(a4),\
1181 __AROS_UFHA(a5),\
1182 __AROS_UFHA(a6))
1184 #define AROS_UFH7(t,n,a1,a2,a3,a4,a5,a6,a7) \
1185 t n ();\
1186 __ASM_PREFIX_U(n)\
1187 __ASM_ARG(a7)\
1188 __ASM_ARG(a6)\
1189 __ASM_ARG(a5)\
1190 __ASM_ARG(a4)\
1191 __ASM_ARG(a3)\
1192 __ASM_ARG(a2)\
1193 __ASM_ARG(a1)\
1194 __ASM_POSTFIX_U(t,n,7)\
1195 __AROS_UFHA(a1),\
1196 __AROS_UFHA(a2),\
1197 __AROS_UFHA(a3),\
1198 __AROS_UFHA(a4),\
1199 __AROS_UFHA(a5),\
1200 __AROS_UFHA(a6),\
1201 __AROS_UFHA(a7))
1203 #define AROS_UFH8(t,n,a1,a2,a3,a4,a5,a6,a7,a8) \
1204 t n ();\
1205 __ASM_PREFIX_U(n)\
1206 __ASM_ARG(a8)\
1207 __ASM_ARG(a7)\
1208 __ASM_ARG(a6)\
1209 __ASM_ARG(a5)\
1210 __ASM_ARG(a4)\
1211 __ASM_ARG(a3)\
1212 __ASM_ARG(a2)\
1213 __ASM_ARG(a1)\
1214 __ASM_POSTFIX_U(t,n,8)\
1215 __AROS_UFHA(a1),\
1216 __AROS_UFHA(a2),\
1217 __AROS_UFHA(a3),\
1218 __AROS_UFHA(a4),\
1219 __AROS_UFHA(a5),\
1220 __AROS_UFHA(a6),\
1221 __AROS_UFHA(a7),\
1222 __AROS_UFHA(a8))
1224 #define AROS_UFH9(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9) \
1225 t n ();\
1226 __ASM_PREFIX_U(n)\
1227 __ASM_ARG(a9)\
1228 __ASM_ARG(a8)\
1229 __ASM_ARG(a7)\
1230 __ASM_ARG(a6)\
1231 __ASM_ARG(a5)\
1232 __ASM_ARG(a4)\
1233 __ASM_ARG(a3)\
1234 __ASM_ARG(a2)\
1235 __ASM_ARG(a1)\
1236 __ASM_POSTFIX_U(t,n,9)\
1237 __AROS_UFHA(a1),\
1238 __AROS_UFHA(a2),\
1239 __AROS_UFHA(a3),\
1240 __AROS_UFHA(a4),\
1241 __AROS_UFHA(a5),\
1242 __AROS_UFHA(a6),\
1243 __AROS_UFHA(a7),\
1244 __AROS_UFHA(a8),\
1245 __AROS_UFHA(a9))
1247 #define AROS_UFH10(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
1248 t n ();\
1249 __ASM_PREFIX_U(n)\
1250 __ASM_ARG(a10)\
1251 __ASM_ARG(a9)\
1252 __ASM_ARG(a8)\
1253 __ASM_ARG(a7)\
1254 __ASM_ARG(a6)\
1255 __ASM_ARG(a5)\
1256 __ASM_ARG(a4)\
1257 __ASM_ARG(a3)\
1258 __ASM_ARG(a2)\
1259 __ASM_ARG(a1)\
1260 __ASM_POSTFIX_U(t,n,10)\
1261 __AROS_UFHA(a1),\
1262 __AROS_UFHA(a2),\
1263 __AROS_UFHA(a3),\
1264 __AROS_UFHA(a4),\
1265 __AROS_UFHA(a5),\
1266 __AROS_UFHA(a6),\
1267 __AROS_UFHA(a7),\
1268 __AROS_UFHA(a8),\
1269 __AROS_UFHA(a9),\
1270 __AROS_UFHA(a10))
1272 #define AROS_UFH11(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) \
1273 t n ();\
1274 __ASM_PREFIX_U(n)\
1275 __ASM_ARG(a11)\
1276 __ASM_ARG(a10)\
1277 __ASM_ARG(a9)\
1278 __ASM_ARG(a8)\
1279 __ASM_ARG(a7)\
1280 __ASM_ARG(a6)\
1281 __ASM_ARG(a5)\
1282 __ASM_ARG(a4)\
1283 __ASM_ARG(a3)\
1284 __ASM_ARG(a2)\
1285 __ASM_ARG(a1)\
1286 __ASM_POSTFIX_U(t,n,11)\
1287 __AROS_UFHA(a1),\
1288 __AROS_UFHA(a2),\
1289 __AROS_UFHA(a3),\
1290 __AROS_UFHA(a4),\
1291 __AROS_UFHA(a5),\
1292 __AROS_UFHA(a6),\
1293 __AROS_UFHA(a7),\
1294 __AROS_UFHA(a8),\
1295 __AROS_UFHA(a9),\
1296 __AROS_UFHA(a10),\
1297 __AROS_UFHA(a11))
1299 #define AROS_UFH12(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) \
1300 t n ();\
1301 __ASM_PREFIX_U(n)\
1302 __ASM_ARG(a12)\
1303 __ASM_ARG(a11)\
1304 __ASM_ARG(a10)\
1305 __ASM_ARG(a9)\
1306 __ASM_ARG(a8)\
1307 __ASM_ARG(a7)\
1308 __ASM_ARG(a6)\
1309 __ASM_ARG(a5)\
1310 __ASM_ARG(a4)\
1311 __ASM_ARG(a3)\
1312 __ASM_ARG(a2)\
1313 __ASM_ARG(a1)\
1314 __ASM_POSTFIX_U(t,n,12)\
1315 __AROS_UFHA(a1),\
1316 __AROS_UFHA(a2),\
1317 __AROS_UFHA(a3),\
1318 __AROS_UFHA(a4),\
1319 __AROS_UFHA(a5),\
1320 __AROS_UFHA(a6),\
1321 __AROS_UFHA(a7),\
1322 __AROS_UFHA(a8),\
1323 __AROS_UFHA(a9),\
1324 __AROS_UFHA(a10),\
1325 __AROS_UFHA(a11),\
1326 __AROS_UFHA(a12))
1328 #define AROS_UFH13(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) \
1329 t n ();\
1330 __ASM_PREFIX_U(n)\
1331 __ASM_(a13)\
1332 __ASM_ARG(a12)\
1333 __ASM_ARG(a11)\
1334 __ASM_ARG(a10)\
1335 __ASM_ARG(a9)\
1336 __ASM_ARG(a8)\
1337 __ASM_ARG(a7)\
1338 __ASM_ARG(a6)\
1339 __ASM_ARG(a5)\
1340 __ASM_ARG(a4)\
1341 __ASM_ARG(a3)\
1342 __ASM_ARG(a2)\
1343 __ASM_ARG(a1)\
1344 __ASM_POSTFIX_U(t,n,13)\
1345 __AROS_UFHA(a1),\
1346 __AROS_UFHA(a2),\
1347 __AROS_UFHA(a3),\
1348 __AROS_UFHA(a4),\
1349 __AROS_UFHA(a5),\
1350 __AROS_UFHA(a6),\
1351 __AROS_UFHA(a7),\
1352 __AROS_UFHA(a8),\
1353 __AROS_UFHA(a9),\
1354 __AROS_UFHA(a10),\
1355 __AROS_UFHA(a11),\
1356 __AROS_UFHA(a12),\
1357 __AROS_UFHA(a13))
1359 #define AROS_UFH14(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) \
1360 t n ();\
1361 __ASM_PREFIX_U(n)\
1362 __ASM_ARG(a14)\
1363 __ASM_ARG(a13)\
1364 __ASM_ARG(a12)\
1365 __ASM_ARG(a11)\
1366 __ASM_ARG(a10)\
1367 __ASM_ARG(a9)\
1368 __ASM_ARG(a8)\
1369 __ASM_ARG(a7)\
1370 __ASM_ARG(a6)\
1371 __ASM_ARG(a5)\
1372 __ASM_ARG(a4)\
1373 __ASM_ARG(a3)\
1374 __ASM_ARG(a2)\
1375 __ASM_ARG(a1)\
1376 __ASM_POSTFIX_U(t,n,14)\
1377 __AROS_UFHA(a1),\
1378 __AROS_UFHA(a2),\
1379 __AROS_UFHA(a3),\
1380 __AROS_UFHA(a4),\
1381 __AROS_UFHA(a5),\
1382 __AROS_UFHA(a6),\
1383 __AROS_UFHA(a7),\
1384 __AROS_UFHA(a8),\
1385 __AROS_UFHA(a9),\
1386 __AROS_UFHA(a10),\
1387 __AROS_UFHA(a11),\
1388 __AROS_UFHA(a12),\
1389 __AROS_UFHA(a13),\
1390 __AROS_UFHA(a14))
1392 #define AROS_UFH15(t,n,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) \
1393 t n ();\
1394 __ASM_PREFIX_U(n)\
1395 __ASM_ARG(a15)\
1396 __ASM_ARG(a14)\
1397 __ASM_ARG(a13)\
1398 __ASM_ARG(a12)\
1399 __ASM_ARG(a11)\
1400 __ASM_ARG(a10)\
1401 __ASM_ARG(a9)\
1402 __ASM_ARG(a8)\
1403 __ASM_ARG(a7)\
1404 __ASM_ARG(a6)\
1405 __ASM_ARG(a5)\
1406 __ASM_ARG(a4)\
1407 __ASM_ARG(a3)\
1408 __ASM_ARG(a2)\
1409 __ASM_ARG(a1)\
1410 __ASM_POSTFIX_U(t,n,15)\
1411 __AROS_UFHA(a1),\
1412 __AROS_UFHA(a2),\
1413 __AROS_UFHA(a3),\
1414 __AROS_UFHA(a4),\
1415 __AROS_UFHA(a5),\
1416 __AROS_UFHA(a6),\
1417 __AROS_UFHA(a7),\
1418 __AROS_UFHA(a8),\
1419 __AROS_UFHA(a9),\
1420 __AROS_UFHA(a10),\
1421 __AROS_UFHA(a11),\
1422 __AROS_UFHA(a12),\
1423 __AROS_UFHA(a13),\
1424 __AROS_UFHA(a14),\
1425 __AROS_UFHA(a15))
1427 /* Call a user function */
1429 #define AROS_UFC0(t,n) \
1430 (((__AROS_UFC_PREFIX t(*)(void))n)())
1431 #define __UFC1(t,n,t1,n1,r1) \
1433 t1 __n1 = (n1);\
1435 register long __d0 __asm__(D0);\
1436 __asm__ (\
1437 "moveml "## r1 ##"/%d7,-(%sp)\n\t "\
1440 __asm__ __volatile__("move.l %1,%%d7"\
1441 :"=r"(__d0)\
1442 :"a"(n)\
1443 :A0,A1,D0,D1,"cc","memory");\
1445 register t1 ___n1 __asm__(D0) = __n1;\
1446 __asm__ (\
1447 "move.l %d0,"## r1 ##"\n\t"\
1448 "jsr (%d7)\n\t"\
1449 "move.l %d0,-4(%sp)\n\t"\
1450 "moveml (%sp)+,"## r1 ##"/%d7\n\t"\
1451 "move.l -12(%sp),%d0\n\t"\
1453 (t)__d0;\
1457 #define AROS_UFC1(t,n,a1) __UFC1(t,n,a1)
1458 #define __UFC2(t,n,t1,n1,r1,t2,n2,r2) \
1460 t1 __n1 = (n1);\
1461 t2 __n2 = (n2);\
1463 register long __d0 __asm__(D0);\
1464 __asm__ (\
1465 "moveml "## r1 ##"/"## r2 ##"/%d7,-(%sp)\n\t "\
1468 __asm__ __volatile__("move.l %1,%%d7"\
1469 :"=r"(__d0)\
1470 :"a"(n)\
1471 :A0,A1,D0,D1,"cc","memory");\
1473 register t2 ___n2 __asm__(D0) = __n2;\
1474 __asm__ (\
1475 "move.l %d0,-(%sp)\n\t"\
1479 register t1 ___n1 __asm__(D0) = __n1;\
1480 __asm__ (\
1481 "move.l %d0,"## r1 ##"\n\t"\
1482 "move.l (%sp)+,"## r2 ##"\n\t"\
1483 "jsr (%d7)\n\t"\
1484 "move.l %d0,-4(%sp)\n\t"\
1485 "moveml (%sp)+,"## r1 ##"/"## r2 ##"/%d7\n\t"\
1486 "move.l -16(%sp),%d0\n\t"\
1488 (t)__d0;\
1492 #define AROS_UFC2(t,n,a1,a2) __UFC2(t,n,a1,a2)
1493 #define __UFC3(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3) \
1495 t1 __n1 = (n1);\
1496 t2 __n2 = (n2);\
1497 t3 __n3 = (n3);\
1499 register long __d0 __asm__(D0);\
1500 __asm__ (\
1501 "moveml "## r1 ##"/"## r2 ##"/"## r3 ##"/%d7,-(%sp)\n\t"\
1504 __asm__ __volatile__("move.l %1,%%d7"\
1505 :"=r"(__d0)\
1506 :"a"(n)\
1507 :A0,A1,D0,D1,"cc","memory");\
1509 register t3 ___n3 __asm__(D0) = __n3;\
1510 __asm__ (\
1511 "move.l %d0,-(%sp)\n\t"\
1515 register t2 ___n2 __asm__(D0) = __n2;\
1516 __asm__ (\
1517 "move.l %d0,-(%sp)\n\t"\
1521 register t1 ___n1 __asm__(D0) = __n1;\
1522 __asm__ (\
1523 "move.l %d0,"## r1 ##"\n\t"\
1524 "move.l (%sp)+,"## r2 ##"\n\t"\
1525 "move.l (%sp)+,"## r3 ##"\n\t"\
1526 "jsr (%d7)\n\t"\
1527 "move.l %d0,-4(%sp)\n\t"\
1528 "moveml (%sp)+,"## r1 ##"/"## r2 ##"/"## r3 ##"/%d7\n\t"\
1529 "move.l -20(%sp),%d0\n\t"\
1531 (t)__d0;\
1535 #define AROS_UFC3(t,n,a1,a2,a3) __UFC3(t,n,a1,a2,a3)
1536 #define __UFC4(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4) \
1538 t1 __n1 = (n1);\
1539 t2 __n2 = (n2);\
1540 t3 __n3 = (n3);\
1541 t3 __n4 = (n4);\
1543 register long __d0 __asm__(D0);\
1544 __asm__ (\
1545 "moveml "## r1 ##"/"## r2 ##"/"## r3 ##"/"## r4 ##"/%d7,-(%sp)\n\t "\
1548 __asm__ __volatile__("move.l %1,%%d7"\
1549 :"=r"(__d0)\
1550 :"a"(n)\
1551 :A0,A1,D0,D1,"cc","memory");\
1553 register t4 ___n4 __asm__(D0) = __n4;\
1554 __asm__ (\
1555 "move.l %d0,-(%sp)\n\t"\
1559 register t3 ___n3 __asm__(D0) = __n3;\
1560 __asm__ (\
1561 "move.l %d0,-(%sp)\n\t"\
1565 register t2 ___n2 __asm__(D0) = __n2;\
1566 __asm__ (\
1567 "move.l %d0,-(%sp)\n\t"\
1571 register t1 ___n1 __asm__(D0) = __n1;\
1572 __asm__ (\
1573 "move.l %d0,"## r1 ##"\n\t"\
1574 "move.l (%sp)+,"## r2 ##"\n\t"\
1575 "move.l (%sp)+,"## r3 ##"\n\t"\
1576 "move.l (%sp)+,"## r4 ##"\n\t"\
1577 "jsr (%d7)\n\t"\
1578 "move.l %d0,-4(%sp)\n\t"\
1579 "moveml (%sp)+,"## r1 ##"/"## r2 ##"/"## r3 ##"/"## r4 ##"/%d7\n\t"\
1580 "move.l -24(%sp),%d0\n\t"\
1582 (t)__d0;\
1586 #define AROS_UFC4(t,n,a1,a2,a3,a4) __UFC4(t,n,a1,a2,a3,a4)
1587 #define __UFC5(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,t4,n4,r4,t5,n5,r5) \
1589 t1 __n1 = (n1);\
1590 t2 __n2 = (n2);\
1591 t3 __n3 = (n3);\
1592 t4 __n4 = (n4);\
1593 t5 __n5 = (n5);\
1595 register long __d0 __asm__(D0);\
1596 __asm__ (\
1597 "moveml "## r1 ##"/"## r2 ##"/"## r3 ##"/\
1598 "## r4 ##"/"## r5 ##"/%d7,-(%sp)\n\t"\
1601 __asm__ __volatile__("move.l %1,%%d7"\
1602 :"=r"(__d0)\
1603 :"a"(n)\
1604 :A0,A1,D0,D1,"cc","memory");\
1606 register t5 ___n5 __asm__(D0) = __n5;\
1607 __asm__ (\
1608 "move.l %d0,-(%sp)\n\t"\
1612 register t4 ___n4 __asm__(D0) = __n4;\
1613 __asm__ (\
1614 "move.l %d0,-(%sp)\n\t"\
1618 register t3 ___n3 __asm__(D0) = __n3;\
1619 __asm__ (\
1620 "move.l %d0,-(%sp)\n\t"\
1624 register t2 ___n2 __asm__(D0) = __n2;\
1625 __asm__ (\
1626 "move.l %d0,-(%sp)\n\t"\
1630 register t1 ___n1 __asm__(D0) = __n1;\
1631 __asm__ (\
1632 "move.l %d0,"## r1 ##"\n\t"\
1633 "move.l (%sp)+,"## r2 ##"\n\t"\
1634 "move.l (%sp)+,"## r3 ##"\n\t"\
1635 "move.l (%sp)+,"## r4 ##"\n\t"\
1636 "move.l (%sp)+,"## r5 ##"\n\t"\
1637 "jsr (%d7)\n\t"\
1638 "move.l %d0,-4(%sp)\n\t"\
1639 "moveml (%sp)+,"## r1 ##"/"## r2 ##"/"\
1640 ## r3 ##"/"## r4 ##"/"\
1641 ## r5 ##"/%d7\n\t"\
1642 "move.l -28(%sp),%d0\n\t"\
1644 (t)__d0;\
1648 #define AROS_UFC5(t,n,a1,a2,a3,a4,a5) __UFC5(t,n,a1,a2,a3,a4,a5)
1650 #endif /* UseRegisterArgs */
1652 #endif /* AROS_MACHINE_H */