EmbDev.net

Forum: µC & Digital Electronics Volatile pointer


Author: Johan (Guest)
Posted on:

Rate this post
0 useful
not useful
I am using mmio to access an external unit from my at90s8515. To access
this device easily I have an pointer that points to the start of the
mmio area. The interesting parts og the code looks like this:

volatile char *mmio =(char *)0x8300;

...
{
...
  mmio[a] = val1;
  mmio[b] = val1 >> 8;
  mmio[c] = val2;
...
}

this is compiled with:
avr-gcc -g -wall -O2 -mmcu=at90s8515 -Wl ...

the disassembled output becommes like this:

  mmio[a] = val1;
  e0:  e0 91 60 00   lds  r30, 0x0060
  e4:  f0 91 61 00   lds  r31, 0x0061
  e8:  42 87         std  Z+10, r20  ; 0x0a
  mmio[b] = val1 >> 8;
  ea:  e0 91 60 00   lds  r30, 0x0060
  ee:  f0 91 61 00   lds  r31, 0x0061
  f2:  85 2f         mov  r24, r21
  f4:  99 27         eor  r25, r25
  f6:  83 87         std  Z+11, r24  ; 0x0b
  mmio[c] = val2;
  f8:  e0 91 60 00   lds  r30, 0x0060
  fc:  f0 91 61 00   lds  r31, 0x0061
 100:  60 87         std  Z+8, r22  ; 0x08

My problem is all these lds r30/r31. That makes me believe that the
compiler treates the pointer as a volatile pointer not a pointer to a
volatile area. Does anyone have any ideas how to optimize this?

Author: samo (Guest)
Posted on:

Rate this post
0 useful
not useful
So funktionier es.

char *volatile mmio =(char *)0x8300;

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.