From mint-bounce@lists.fishpool.fi Sun Nov 2 17:19:39 2008 Message-ID: <490E26E9.2080700@freesbee.fr> Date: Sun, 02 Nov 2008 23:17:13 +0100 From: =?ISO-8859-1?Q?Vincent_Rivi=E8re?= User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: mint Subject: Re: [MiNT] arguments in registers instead of stack in gcc References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: vincent.riviere@freesbee.fr Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.sparemint.org id mA2MJcsK015762 Miro Kropacek wrote: > is there any way how to force gcc to pass arguments to assembler > function in some specified registers instead of stack? Some compilers > allow something like "func(register __a0 int* pointer)" declarations. It is possible to write an inline function wrapping the call to the assembler function. It seems to work as expected, but I'm not sure it will always be safe... Let say that asmfunc() is an assembly function taking a pointer in a0 as an argument. You can use the inline function call_asmfunc() from your C code. $ cat paramreg.c static __inline__ void call_asmfunc(int* pointer) { register int* param __asm__("a0") = pointer; __asm__ volatile ("jsr _asmfunc" : /* outputs */ : "g"(param) /* inputs */ : "d0", "d1", "a1" /* clobbered regs */ ); } int arr[3]; void test() { call_asmfunc(arr); } $ m68k-atari-mint-gcc -S paramreg.c -o - -O2 -fomit-frame-pointer #NO_APP .text .even .globl _test _test: lea _arr,%a0 #APP | 5 "paramreg.c" 1 jsr _asmfunc | 0 "" 2 #NO_APP rts .comm _arr,12 -- Vincent Rivière