Go Down

Topic: How to write an inline assembly instruction for Due? (Read 480 times) previous topic - next topic

jrullan

Hello all,

First I apologize if the question is too simple but I have never written any assembly before for the Due. I need a function that can use the ROR instruction (rotate right) available in the Thumb-2 instruction set on the Cortex processor. I thought that by using __ROR I would have access to it but I dont.

Code: [Select]
*dataBytes = *dataBytes + __ROR((*s0 & m),32+b);

Basically I need to rotate the resulting int after the *s0 & m operation by 32+b bits and sum it up.

How can I create this code in my program?

jrullan

Turns out that not all of the assembly instructions are "exposed" in the Arduino IDE.  I  had to implement it like this:

Code: [Select]

__attribute__( ( always_inline ) ) static __INLINE uint32_t __ROR(uint32_t value, uint32_t shift)
{
  uint32_t result;
 
  __ASM volatile ("ror %0, %1, %2" : "=r" (result) : "r" (value) , "r" (shift) );
  return(result);
}

Go Up