Re: calling assembly language routines from 'C'
- From: "Hunter" <ankit.chaturvedi@xxxxxxxxx>
- Date: 8 Apr 2007 17:24:28 -0700
On Apr 8, 9:30 am, 2Penny <lw_rog...@xxxxxxxxxxxxx> wrote:
Thank you Stephane. Any pointers are appreciated and I can
verify (and I intend to) via the ARM website and the ARM Thumb
Proceedure Call Standard. Good stuff !! My 'C' seems to be
rusty though. I haven't looked yet, but is there example
code that can be adapted of the 'C' call and the responding
ASM code?
Without going further though, this is a help.
Thanks again,
2Penny
Stephane wrote:
On Apr 7, 5:16 pm, 2Penny <lw_rog...@xxxxxxxxxxxxx> wrote:
Gentlemen;
I've written a couple of routines in ARM assembly language because
I've gotten to work in assembly language a lot for a number of years
and I've now gotten to work with an ARM
assembler/compiler/debugger/downloader, ARM9 equipped board and JTAG
unit and I've built up assembly language versions of getchar()
and putchar(). The routines work fine inside an ASM program
called "echo" and I'd like to use these routines in a 'C'-ish
program called "echo".
So how does one call ASM routines from 'C'? Can anyone here
point me in the right direction?
2Penny (as in "that's my 2 cents worth")
Hi,
If you want complete information, you can find it on ARM website. What
you are looking for is the "Arm Thumb Procedure Call
Standard" (ATPCS).
In brief, you call your asm function by its symbol (you need to export
it from your asm source), with in consideration that your parameters
will be passed in order in r0-r4, and the return value will be read in
r0. If you have more than two parameters, parameters from the 5th on
are passed on the stack. If you use complex data (bigger than an int)
be aware that, when counting your argument registers, they will
require as many registers as they size in "int size unit".
You might need to modify your ASM if it doesn't comply with these
rules. (Or maybe you can specify another ABI instead of ATPCS, but my
knowledge reaches its limit there.)
Cheers,
Stephane
Hi Stephane,
Is Thumb PCS necessary for calling a asm
routine? I mean, the standard APCS(ARM Procedure Call Standard) is
what should be sufficient. Also would the processor need to be changed
to thumb mode at the start of each routine in assembly while using
ATPCS? Of course if it is thumb mode instructions, it is, otherwise
it shouldn't be necessary at all. My guess is using the standard APCS
would do just fine, unless there is arm-thumb interworking involved,
isn't it?
Regards,
Ankit Chaturvedi
.
- Follow-Ups:
- Re: calling assembly language routines from 'C'
- From: 2Penny
- Re: calling assembly language routines from 'C'
- References:
- calling assembly language routines from 'C'
- From: 2Penny
- Re: calling assembly language routines from 'C'
- From: Stephane
- Re: calling assembly language routines from 'C'
- From: 2Penny
- calling assembly language routines from 'C'
- Prev by Date: Re: calling assembly language routines from 'C'
- Next by Date: Re: __huge_val error
- Previous by thread: Re: calling assembly language routines from 'C'
- Next by thread: Re: calling assembly language routines from 'C'
- Index(es):
Relevant Pages
|