this bug was introduced in r11806, here is my comment:
https://sourceforge.net/p/sdcc/feature-requests/699/#93cf/df3c
i also managed to make an example that shows the generation of invalid code.
ver:
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15 4.0.3 #11806 (MINGW64)
cmdline:
sdcc -mgbz80 --fsigned-char --no-std-crt0 -I ..\..\gbdk\include -I ..\..\gbdk\include\asm -I src\include -c --max-allocs-per-node 50000 --no-peep test4.c -o build\test4.rel
result:
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
ld e, #0x00
ld hl, #_scene_to_map_x_65536_4
ld (hl), h
instead of:
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
ld e, h
ld d, #0x00
ld hl, #_scene_to_map_x_65536_4
ld (hl), e
in 4.0.3 #11800 (MINGW64)
suggested code should be:
ld e, h
ld hl, #_scene_to_map_x_65536_99
ld (hl), e
Fixed in [r11818].
When --reserve-regs-iy was specified, the bug also affected z80-related ports other than gbz80.
wow! thank you!