Is the transfer bit in SREG a general purpose bit usable by the application developer or does avr-libc reserve use of the bit?
TWI C source code
The floating-point routines (at least in avr-libc up to 1.4.x) use it
Please don't send me PMs, use email if you want to approach me personally.
There was a similar discussion before. Look here.
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.
The Board helps those that help themselves.
.... 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).
© 2020 Microchip Technology Inc.