Blinkinlabs / ch554_sdcc

CH554 software development kit for SDCC
297 stars 70 forks source link

x and x2 should not be volatile #19

Closed nerdralph closed 4 years ago

nerdralph commented 4 years ago

https://github.com/Blinkinlabs/ch554_sdcc/blob/master/include/debug.c#L164 Making them volatile stops SDCC from doing constant folding and propagation, which bloats the code size. By making them non-volatile, the blink example compiles to 364 bytes instead of 700.

cibomahto commented 4 years ago

Good find! And you've verified that the code still writes the intended value to TH1? Happy to accept a pull request or make the change, whichever you'd prefer.

nerdralph commented 4 years ago

I haven't tested the UARTs on my modules, but the asm code looks good with 16M FREQ_SYS: mov _TH1,#0x98 0-0x98 = 104, 16M/16/104 = 9,615bps With 12M for FREQ_SYS it 0xB2 instead of 0x98.

cibomahto commented 4 years ago

Excellent!