• Advertisement
Sign in to follow this  

inline assembly in ARM

This topic is 4332 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

guys can someone show me how to do inline assembly in arm that communicates back the result back to the application for example;
int multiply( int x,int y )
{
   int result=0;
   _asm(....); //i d0nt knw how to do this operation in asm

   return result;
}
[/source ]
can you guys show me on how to add,sub,mult and div in arm assembly?

Share this post


Link to post
Share on other sites
Advertisement
Hey bud,

I did ARM assembler at uni for a bit, but i can't remember much of it. However i did manage to find this seemingly excellent PDF of the language, including an instruction set.

Download Here!

Hope it helps,

Dave

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
If (as I suspect) you're asking in relation to implementing a fixed-point math library, you shouldn't need to do this. Here's a straightforward implementation of s15.16 fixed point:

#define fxadd(a,b) ((a)+(b))
#define fxsub(a,b) ((a)-(b))
#define fxmul(a,b) ((int)((long long)(a)*(b)>>16))
#define fxdiv(a,b) ...
#define fxsqrt(a,b) ...

If you're using a halfway decent optimizing compiler, the above will give you decent results (really - the mul solution surprised me greatly when I ran across it, but it actually compiles through to the expected "smull .../ lsr #16/etc)). fxdiv and fxsqrt are actually functions, because ARM doesn't supply a div or sqrt instruction. Implement them entirely in C or assembly or a mixture as it suits you. Try Google for that, there are a number of ARM-specific treatments for both of those problems just sitting out there.

And as mentioned above and elsewhere, you really need to understand the problem you're trying to solve before slapping someone else's solution on it. Fixed-point math doesn't replace floating-point math; it provides a significantly less flexible and more range-limited (though much faster) approximation of R.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement