fix(examples): z80-led-chaser-c dir must be signed char (SDCC z80)
SDCC treats plain `char` as unsigned on Z80, so `dir = -1` read back as 255, `if (dir > 0)` was always true, the "walk right" branch never ran, and the bit just shifted left until it fell off the end and the LEDs went dark after one pass. Use `signed char dir`. Verified in a chip-WASM harness: with plain char the chaser does 8 LED writes then stops; with signed char it walks the bit back and forth continuously (14894 writes). Completes the C example fix together with dropping --code-loc 0x100 in c_compile.py. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
e79368a04a
commit
a57951d854
|
|
@ -58,7 +58,10 @@ static void delay(unsigned int loops) {
|
|||
|
||||
void main(void) {
|
||||
unsigned char bit = 0x01;
|
||||
char dir = 1; /* +1 = walking left, -1 = walking right */
|
||||
/* MUST be signed: SDCC treats plain \`char\` as unsigned on Z80, so
|
||||
dir=-1 would read back as 255, the "walk right" branch would never
|
||||
run, and the bit would just shift left off the end and stay dark. */
|
||||
signed char dir = 1; /* +1 = walking left, -1 = walking right */
|
||||
while (1) {
|
||||
LED_OUT = bit;
|
||||
delay(5000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue