bebbo / gcc

Bebbo's gcc-6-branch for m68k-amigaos
GNU General Public License v2.0
33 stars 11 forks source link

gcc 13.1 - function parameters in registers #202

Closed michalsc closed 1 year ago

michalsc commented 1 year ago

Hello!

I've just had a look at Amiga13 branch. The gcc 13.1 seems to work just as good as I would expect it, but I am mssing an option to pass parameters to a function through registers. For function calls the proto/macros.h can be used, but, is there a way to do that in case of implementations? If not, it is not a big harm since I could just wrap functions of my own library in similar manner as it is done on AROS.

michal@DevelPC:~$ cat a.c
int foo(int a asm("d0"), int *b asm("a0"))
{
        return *b / a;
}

michal@DevelPC:~$ /opt/amiga/bin/m68k-amigaos-gcc-13.1.1 -S -Os -m68040 a.c
michal@DevelPC:~$ cat a.s
#NO_APP
        .text
        .align  2
        .globl  _foo
_foo:
        move.l 8(sp),a0  ; Here arguments are fetched from the stack
        move.l (a0),d0
        divs.l 4(sp),d0
        rts
michal@DevelPC:~$
bebbo commented 1 year ago
m68k-amigaos-gcc -Os -S a.c && less a.s
#NO_APP
        .text
        .align  2
        .globl  _foo
_foo:
        move.l d0,-(sp)
        move.l (a0),-(sp)
        jsr ___divsi3
        addq.l #8,sp
        rts
michalsc commented 1 year ago

Wow, that's fast! Will try ASAP. Thanks!

michalsc commented 1 year ago

Works as expected. Thanks and closing! :-D 👍