Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] calling asm routine from c

2004-12-19 by Robert Adsett

At 08:13 PM 12/19/04 +0000, you wrote:
>The problem I have is with function:
>int GetCharTimeout(int timeout)
>The input and output parameters are transfered thru R0 register.
>But the function is using R1 and R2 registers too.
>Q: How to tell the C code that function in assembler uses R1 and R2
>registers to put it on stack before call. Now I'm doing it in this
>way:
>int getChar(int timeout) {
>   int ret;
>   _asm {
>     push {r1,r2}
>     bl GetChar
>     pop {r1,r2}
>     mov ret, r0
>   }
>   return ret;
>}
>Is there any other way to do the same simplier?

This may be a bit pedantic, but I'd write an assembly shell that conforms 
to the procedure call standard for the ARM and use it to call your assembly 
routine. The C call should then be just about transparent.

Or you could just rewrite your existing routines to conform to the standard.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.