Atomically incremented sequence number using LDREX/STREX for GCC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-03-22 8:18 PM
Atomically incremented sequence number using LDREX/STREX for GCC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:29 AM
gcc warns because you list operands as input/output.
List them as clobbered (dunno how to have named clobbered operands though).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:29 AM
It was my impression that ''clobbered'' is specifically for registers used explicitly in the ASM code - that's the primary reason for using symbolics, so the compiler can determine for itself which registers to use, because it selects them itself. And as you note, there does not appear to be a way to denote ''clobbered'' symbolics.
I suspect GCC warns, because it is not fully aware of the STREX and LDREX instruction formats. That's just a guess, but I did an experiment. I replaced LDREXH with LDRH, replaced STREXH with STRH (removing the result register argument), and removed the ''result'' input/output specifier, and the CMP instruction which reads ''result''. That code produced no warnings, which implies to me that GCC understands the nature of LDRH and STRH operands, but not LDREXH and STREXH operands - otherwise it would have continued to warn about the ''temp_reg'' usage.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:29 AM
D'oh! Please disregard 2nd and 3rd paragraphs of my prior post.
Bad experiment, I neglected to remove the initialiser from ''temp_reg''. When I did so, GCC *did* warn about its use, so that guess of mine was wrong. Sorry about that!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:29 AM
Actually, reading
www.cs.dartmouth.edu/~sergey/cs108/2009/gcc-inline-asm.pdf
it says you should use =&r for temporary registers. Output only will also get rid of the initialization warning.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:29 AM
