I wonder if building this table can be sped up by noticing a recurring pattern?
x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ... 254 255
f(x) 0 0 1 2 3 3 4 5 6 6 7 8 9 9 10 11 12 12 ... 190 191
So something like sta table,y
iny
sta table,y
adc $0
iny
sta table,y
adc $0
iny
sta table,y
adc $0
iny
used as the loop body that should be repeated 64 times, should work. Will it take less than 6000 cycles total?
I didn't check your code worked.. just copied it and ran the inner part of the loop once, but according to https://www.masswerk.at/6502/
It's about 2x faster. Your code uses 44 CPU cycles x 64
Edit: plus a branch instruction, maybe that adds 3 cycles x 64 I guess