Q: How to access global variables in c in assember&#6531

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

inline assemblers in c file, in IAR32

I read the guide doc, but too limited info from that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What are you trying to access exactly? A C declared variable that you want access to in inline assembly?

For gcc it's done like this:
#define SETREG( sregister, regval ) \
__asm__( "mtsr %0, %1\n" \
: \
:"X"(sregister), "r"(regval) )

But I don't know for IAR. Maybe it's similar.

11011110101011011100000011011110

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know much about avr32 C yet, but many compilers put an underscore in front of C variables. So int foo; would be accessed as _foo.

However, why not look at a link map or assembly listing from the compiler? That should tell you for sure.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

my problem is that i have the sample code in gcc but not in IAR32

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For IAR try:
asm ("stm --sp, r0-r7");

-steph.