Topic : Long integer (64) and inline assembler

Forum : ARM

Original Post
Post Information Post
April 1, 2010 - 11:21am
Guest

Hi

I want do some computation on two register lenght integer variable, something like this:

register int64_t TmpData asm("r0");
int32_t Dummy;

TmpData = AgrTab[DataType].sum;
asm(
"lsl %2, %1, #6\n"
"bic %2, #0x200000\n"
"umlal r0, r1, %2, %2\n"
: "+r" (TmpData)
: "r" (DataValue), "r" (Dummy)
: "cc"
);
AgrTab[DataType].sum = TmpData;

How should I do this, avoiding forcing usage of specific registers?

Replies
Post Information Post
+1
0
-1
January 7, 2011 - 6:13pm
Guest

Hi Cezary,

Sorry, I don't have an answer for this (yet), but I have a similar need. Would you mind posting what you did to accomplish this?

I am implementing a digital FIR filter. For maximum computational/speed efficiency I would like to use the UMLAL ("Unsigned multiply with accumulate (32 x 32 + 64), 64-bit result") instruction for each coefficient. However, I understand that my algorithm will need to be considerate of the contents of whatever registers it uses. Perhaps I should just save the contents of r0 and r1 at the beginning of this function and then restore them at the end? But perhaps the compiler might be using these registers for other variables, and I'd need to reserve them.

1) Is there a way that I can write this code in pure C (not referencing specific hardware/registers) that the compiler will be able to optimize using UMLAL instructions? I suppose I could just try writing it and see what output results...
2) Is there a way I can reserve registers in a C function using the gcc compiler?
3) Is there a way that I can tell the compiler/assembler that I don't care which registers I get?

All insight appreciated.