LPC111x MULS instruction error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC111x MULS instruction error

908件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Audiomonster on Sat Dec 26 20:34:10 MST 2009
Hi,

I am trying to use assembly programming, and in particular, the MULS instruction in a C file.

I first do:

void test(unsigned int a, unsigned int b)
{
    a = a * b;
}

The routines compiles into:

0x00000164 <test>:    push {r7, lr}
0x00000166 <test+2>:  sub  sp, #8
0x00000168 <test+4>:  add  r7, sp, #0
0x0000016a <test+6>:  str  r0, [r7, #4]
0x0000016c <test+8>:  str  r1, [r7, #0]
    a = a * b;
0x0000016e <test+10>: ldr  r3, [r7, #4]
0x00000170 <test+12>: ldr  r2, [r7, #0]
0x00000172 <test+14>: muls r3, r2
0x00000174 <test+16>: str  r3, [r7, #4]
}
0x00000176 <test+18>: mov  sp, r7
0x00000178 <test+20>: add  sp, #8
0x0000017a <test+22>: pop  {r7, pc}

So I can see the muls instruction being issued and it takes 2 bytes, fine.

Now I try to do the same, directly.

void test(unsigned int a, unsigned int b)
{
    asm("muls r3,r2;");
}

I get the following error:

\AppData\Local\Temp\cc9rrcik.s: Assembler messages:
\AppData\Local\Temp\cc9rrcik.s:1838: Error: instruction not supported in Thumb16 mode -- `muls r3,r2'

My first test proves that I should be able to issue the instruction inside this file.
Is there some particular directive I should include to make this work ?

Thanks!
0 件の賞賛
返信
2 返答(返信)

857件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Mon Jan 04 07:46:47 MST 2010

Quote: Audiomonster

Now I try to do the same, directly.

void test(unsigned int a, unsigned int b)
{
    asm("muls r3,r2;");
}

I get the following error:

\AppData\Local\Temp\cc9rrcik.s: Assembler messages:
\AppData\Local\Temp\cc9rrcik.s:1838: Error: instruction not supported in Thumb16 mode -- `muls r3,r2'

My first test proves that I should be able to issue the instruction inside this file.
Is there some particular directive I should include to make this work ?

Thanks!



Hi Audiomonster,

It appears that when the compiler passes your assembly code across to the assembler, it is not flagging that you are using ARM's unified assembler syntax.

Try changing your code to:

void test(unsigned int a, unsigned int b)
{
asm(".syntax unified");
    asm("muls r3,r2;");
}

This should then build correctly.
0 件の賞賛
返信

857件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bytethedust on Tue Dec 29 03:07:12 MST 2009
Have you tried
mul r3,r2?
0 件の賞賛
返信