This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Inline ARM assembler and the sp register
- From: Andrew Haley <aph at gcc dot gnu dot org>
- To: "Richard Tew" <richard dot m dot tew at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 2 May 2006 14:28:38 +0100
- Subject: Re: Inline ARM assembler and the sp register
- References: <952d92df0605020304x56b9d855rb45a9e2c6d8aba60@mail.gmail.com>
Richard Tew writes:
> Hi,
>
> I am using the inline assembly functionality of gcc (gcc 4.1.0
> compiled as part of the devkitpro/devkitarm package which
> uses mingw/msys on Windows). What I am trying to do is
> port Stackless Python, which copies portions of the stack
> off and back on, as it switches between microthreads.
>
> The problem is, gcc preserves the stack pointer on entry to the
> function and restores it at the end, so while I may copy around
> portions of the stack with the presumption my modified stack
> pointer will be used on exit of the function, what I actually get
> is the modified stack, but the old stack pointer restored over
> my modified one.
>
> I can hack a solution. Looking at the disassembly in the
> debugger I am using, I see that sp is preserved in r7, so if I
> modify my inline assembler to modify r7 instead of sp,
> Stackless Python works fine.
Why don't you just write the stack-exchanging routine in pure asm? It
seems to me that inline asm is just the wrong tool for the job.
Andrew.