benilla-re systems structs docs

s_formatStates

global · crt

Address
0x8161e0 · 89 bytes, up to 0x816238
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.

class01234567
other00000000
%10000001
.04440000
*03305000
002235500
1 to 903335500
space # + -02200000
F I L N h l w06666660
B C E G S X Z c d e f g i n o p s u x07777770

The derivation is in the doc.