s_formatStates
global · crt
- Address
0x8161e0· 89 bytes, up to0x816238- Type
uint8_t[89]- Meaning
- Holds __output's byte classes in low nibbles from 0x20 and its next states in high nibbles at class * 8 + state
- Confidence
- verified, proof one
- Finding
- crt/printf#the-format-state-machine
Finding: The format state machine in crt: formatted output
__output reads the format a byte at a time until its NUL. A byte's class and the state give
the next state: 0 normal, 1 percent, 2 flag, 3 width, 4 dot, 5 precision, 6 size, 7 type. Bytes
outside 0x20 to 0x78 are of class other. The normal state writes the byte, so %% writes %
and a byte of class other ends a conversion by being written. State 1 clears the flags and width
and sets the precision to -1. * reads an int: a negative width sets - and is negated, a
negative precision is -1. Digits accumulate in 32 bits. I is a size only before 64, else
written. F, L and N do nothing.
| class | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| other | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
% | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
. | 0 | 4 | 4 | 4 | 0 | 0 | 0 | 0 |
* | 0 | 3 | 3 | 0 | 5 | 0 | 0 | 0 |
0 | 0 | 2 | 2 | 3 | 5 | 5 | 0 | 0 |
1 to 9 | 0 | 3 | 3 | 3 | 5 | 5 | 0 | 0 |
space # + - | 0 | 2 | 2 | 0 | 0 | 0 | 0 | 0 |
F I L N h l w | 0 | 6 | 6 | 6 | 6 | 6 | 6 | 0 |
B C E G S X Z c d e f g i n o p s u x | 0 | 7 | 7 | 7 | 7 | 7 | 7 | 0 |
The derivation is in the doc.