avr-gcc Feature: Inline asm and volatile

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

F'up of avr-gcc: New Features?

skeeve wrote:
Perhaps a mechanism for marking in-line assembly so that it will not be reordered with respect to volatile accesses.
Perhaps by putting volatile in the clobber list.
memory clobber is a bit of a bludgeon.

For that matter, it might be good to be able to "pass" a pointer into in-line assembly and tell the compiler that only its target might be clobbered.

This feature is already there.

Use "asm volatile" instead of "asm".

Notice that volatile is not a subset of a memory clobber, nor the other way round:

"¢ volatile actions are volatile actions
"¢ memory accesses are memory accesses

If a memory clobber is too intrusive, you may want to read GCC: Assembler Instructions with C Expression Operands that shows an example how to mark only a specific memory area as clobbered.

avrfreaks does not support Opera. Profile inactive.

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

SprinterSB wrote:
F'up of avr-gcc: New Features?
skeeve wrote:
Perhaps a mechanism for marking in-line assembly so that it will not be reordered with respect to volatile accesses.
Perhaps by putting volatile in the clobber list.
memory clobber is a bit of a bludgeon.

For that matter, it might be good to be able to "pass" a pointer into in-line assembly and tell the compiler that only its target might be clobbered.


This feature is already there.

Use "asm volatile" instead of "asm".

No. According to documentation,
using "asm volatile" does not cause avr-gcc to treat the in-line assembly as a volatile access.
It simply notifies the compiler that the in-line assembly does something useful the compiler does not know about.
It will not optimize away asm volatile that is reached.
Reordering is still possible
Quote:

Notice that volatile is not a subset of a memory clobber, nor the other way round:

• volatile actions are volatile actions
• memory accesses are memory accesses

If a memory clobber is too intrusive, you may want to read GCC: Assembler Instructions with C Expression Operands that shows an example how to mark only a specific memory area as clobbered.

If I understand the magic example, a colon is missing.

International Theophysical Year seems to have been forgotten..
Anyone remember the song Jukebox Band?

Last Edited: Tue. Jan 22, 2013 - 02:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ja, a typo.

avrfreaks does not support Opera. Profile inactive.