Reply by Anders Lindgren December 11, 20072007-12-11
Nafa3 wrote:
> Hi
>
> The function below return a 32 bits of strong weight :
>
> static __inline int MULSHIFT32(int x, int y)
> {
> int zlow;
> __asm {
> smull zlow,y,x,y
> }
>
> return y;
> }
> I compiled it on IAR But unfortunately IAR always generates errors
> Error[Pe020]: identifier "__asm__" is undefined
> Error[Og005]: Unknown symbol in inline assembly: "zlow"
> ...

Hi,

From what I can see, the errors should have read:

Error[Ue001]: The user tries to use inline assembler syntax from another
vendor.
Error[Ue002]: The user tries to use an assembler instruction not
available on the MSP430.
Error[Ue003]: The user tries to build an application that assumes that
int:s are 32 bits with tools where int:s are 16 bit.

Try to rewrite the function so that it's written in plain C, use "long"
or "int32_t" to get 32 bit data. It might not be as efficient, but at
least it works.

So, under the assumtion that we're talking about the ARM "smull"
instruction, the code would look something like the following:

/* The high 32 bits of a signed 32*32=>64 bit multiplication. */
static long MULSHIFT32(long x, long y)
{
return ( ((long long) x) * ((long long) y) ) >> 32;
}

Remember to use "long" (or a typedef) instead of "int" in all other
locations in your application where you assume they can contain 32 bits.

-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.

Beginning Microcontrollers with the MSP430

Reply by Paul Curtis December 8, 20072007-12-08
> The function below return a 32 bits of strong weight :
>
> static __inline int MULSHIFT32(int x, int y)
> {
> int zlow;
> __asm {
> smull zlow,y,x,y
> }
>
> return y;
> }
> I compiled it on IAR But unfortunately IAR always generates errors
> Error[Pe020]: identifier "__asm__" is undefined
> Error[Og005]: Unknown symbol in inline assembly: "zlow"

Ok, even given the syntax problems and non-reading of the manual, how on
earth are you going to run a smull instruction on an MSP430?

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors
Reply by Nafa3 December 7, 20072007-12-07
Hi

The function below return a 32 bits of strong weight :

static __inline int MULSHIFT32(int x, int y)
{
int zlow;
__asm {
smull zlow,y,x,y
}

return y;
}
I compiled it on IAR But unfortunately IAR always generates errors
Error[Pe020]: identifier "__asm__" is undefined
Error[Og005]: Unknown symbol in inline assembly: "zlow"
...

Please Help me.
Thank you