Is the transfer bit in SREG a general purpose bit usable by the application developer or does avr-libc reserve use of the bit?
SREG Transfer bit / avr-libc
The floating-point routines (at least in avr-libc up to 1.4.x) use it
internally.
The floating-point routines (at least in avr-libc up to 1.4.x) use it
internally.
GCC can use it, but only in some corner cases (loading non-immediate registers etc, shift 16 bit registers.) Note that the instructions concerned with T flag also include BLT and BLD not just SET and CLT.
And GCC is not saving/restoring the bit. So using it is on your own risk!
And GCC is not saving/restoring the bit.
Except that anything that saves/restores SREG should be safe, so I'm not really sure how dangerous it would be to use it.
.... So using it is on your own risk!
Since the SREG is saved/restored between calls it should be safe within that aspect. What I was worried about is functions in avr-libc using the T-bit to transfer info between function calls. I know Keil used a flag bit in the status register of the 8051 to pass info between functions but didn't document it so peoples code would end up breaking when the tried to use the flag bit.
> Since the SREG is saved/restored between calls
No, only within interrupt handlers. Calling another function doesn't
preserve SREG (but wouldn't modify the T bit either).