Using MULS instruction in Cortex M0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using MULS instruction in Cortex M0

940 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mahna on Sat Dec 31 08:43:51 MST 2011
When I use MULS instruction in inline assembly, the compiler flags an error.
When I put  ".syntax unified" directive, the error is as follows :
Error: Thumb-2 MUL must not set flags
How to use multiply instruction in inline assembly ?
0 Kudos
Reply
2 Replies

725 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by OA santana on Tue Feb 28 05:49:21 MST 2012
My solution. I know it is not an inline command but it might help you.

/************************* some code ************************* /
/**
  * @param r0=a
  * @param r1=b
  * @param r2=c
  * @retval r0
*/
__ASM volatile int16_t somemath (int16_t a,int16_t b,int16_t c) {
[INDENT]muls r0,r1,r0
adds r0, r2,r0
BX lr[/INDENT]
}

int main () {
[INDENT]  int16_t tmp;
  tmp =  somemath (10,3,4);
  if (tmp != 34) {
    /* error */
  } else {
   /*expected value. */
  }[/INDENT]
return(0);
}

/************************* end code ************************* /
Information that might be of your interest :
Procedure Call Standard for the ARM® Architecture
(Document number: ARM IHI 0042D, current through ABI release 2.08)
Hope that helped you.
0 Kudos
Reply

725 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fastmapper on Sat Dec 31 10:35:36 MST 2011
I have had no problem using the MULS instruction.  Here is a code sequence that I have used successfully for a LPC1227:

    .syntax unified
    muls r5, r3

We could help you more if you could provide a short code sequence that fails along with the associated build settings (including the target device).
0 Kudos
Reply