On 13.05.15 15:49, Britton Kerin wrote: I've got some code with tight timing that works at 10MHz only if I register lock some globals as described here:
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_regbind I'm using registers r2 through r5. The FAQ seems to be saying that this is safe in the above faq_regbind section, and also in http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage but it also says that extreme care is required to make sure other code including possibly used library functions doesn't use these registers. I'm trying to figure out how to do that. Currently, I have the global uint8_t register vars declared at the top of the source file that uses them, and I compile all my source files with -ffixed-r2 -ffixed-r3 -ffixed-r4 -ffixed-r5 as the GCC manual advises. But I haven't recompiled avr-libc that way. This seems to work, but is it really ok? What I don't know is what I must do to ensure that avr-libc isn't using the registers in an unsafe way. It does use the registers: $ avr-objdump -d /usr/lib/avr/lib/libc.a > /tmp/libc $ egrep '\<r2\>' /tmp/libc | more 1ac: 28 2e mov r2, r24 1f4: 20 2e mov r2, r16 204: 82 2d mov r24, r2 ... and apparently since there are no push-pop pairs, it doesn't seem guaranteed that its saving/restoring them. But I'm told that it might not need to, because a compiler optimization causes only clobbered registers to be preserved. I'm told that what I need to check is whether avr-gcc "pushes the clobber list"? Britton _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list