CodeWarrior Development Studio for Freescale MPC55xx version 2.0 unknown error

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

CodeWarrior Development Studio for Freescale MPC55xx version 2.0 unknown error

3,219 Views
alediano
Contributor I
I wrote this macro:

#define watch_dog() {register int lz; asm(" mfspr lz, TSR " ) ; asm(" oris  lz, lz, 0x8000 " ) ; asm(" mtspr TSR, lz " ) ;}

Then, when I use it, compiler says:
 Error   : lz was not assigned to a GPR register (try using register qualifier)


I'm using CodeWarrior Development Studio for Freescale MPC55xx version 2.0.
Could you help me please?

Thanks



Message Edited by alediano on 2007-06-06 10:01 AM
Labels (1)
0 Kudos
7 Replies

588 Views
Voxan
Contributor III
Hi there,

cause the scope of a local variable, in this compiler, is the function, not a block.
in other words if you implement a function, instead of your macro, you'll be good

void watch_dog() { \
   register int lz; \
   asm(" mfspr lz, TSR " ); \
   asm(" oris  lz, lz, 0x8000 " ); \
   asm(" mtspr TSR, lz " ); \
}

Hope this helps...
0 Kudos

588 Views
alediano
Contributor I
Oh yes, thanks, I knew it, but it's very strange, isn't it?
Is it a compiler bug or should we define the macro in another way?
In the previous CodeWarrior MPC55xx version 1.5 that macro worked!

Regards

0 Kudos

588 Views
Voxan
Contributor III
hmmm, looks like a compiler inline asm regression...

I'll get confirmation from engineering, in the meantime, you may want to log an SR in our tracking system at
http://www.freescale.com/webapp/sps/site/homepage.jsp?nodeId=054670

pls stay tunned

Cheers

0 Kudos

588 Views
Voxan
Contributor III
this workaround seems to work for me...

#define watch_dog() {register int lz; asm { mfspr lz, TSR; oris  lz, lz, 0x8000; mtspr TSR, lz; } }

defining an asm instruction block instead individuals...

Hope this helps...
0 Kudos

588 Views
Voxan
Contributor III
General inofrmation:

Freescale compilers based on the 4.x front end are now using the GCC-style inline asm syntaxe.

The original syntaxe was not following that GCC-style.

Hope this helps...
0 Kudos

588 Views
Voxan
Contributor III
to make is clear, if it was not :smileywink:

asm volatile ( "mfmsr _cpulevel;");

becomes (in GCC-Style syntax):

asm volatile ( "mfmsr %0" : "=r" (_cpulevel));

becomes (in CW-Style syntax):

asm volatile ( mfmsr _cpulevel:smileywink:;

You can find more information about GCC-Style syntax at http://gcc.gnu.org/onlinedocs/gcc-3.4.0/gcc/Extended-Asm.html#Extended%20Asm

Hope this helps...
0 Kudos

588 Views
alediano
Contributor I
Thank you very much.
0 Kudos