Bug in SDCC code generation?

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Bug in SDCC code generation?

Post by jorgegv »

Hi guys,

I think I have found a problem when compiling with SDCC. The symptoms are:

Code: Select all

make -f Makefile-48 engine/src/bullet.o
Compiling engine/src/bullet.c ...
engine/src/bullet.c:1033: error: syntax error
  ^---- ld h, iyl
engine/src/bullet.c:1039: error: syntax error
  ^---- ld h, iyl
make: *** [Makefile.common:107: engine/src/bullet.o] Error 1
I have checked the asm code generated by SDCC, and those instructions are indeed there:

Code: Select all

(snippet from engine/src/bullet.c.asm)
...
        inc     hl
        ld      (hl), d
;engine/src/bullet.c:84: bs->xthresh = BULLET_SPRITE_XTHRESH;
        ld      l, b
        ld      h, iyl
        ld      de,0x0011
        add     hl, de
        ld      (hl),0x04
;engine/src/bullet.c:85: bs->ythresh = BULLET_SPRITE_YTHRESH;
        ld      l, b
        ld      h, iyl
        ld      de,0x0012
        add     hl, de
I know that "ld h, iyl" instruction is an undocumented one, but according to this reference, it is not a valid one due to ambiguity. And Z80ASM does not chew it (correctly, it seems).

Did I strike an SDCC code generation bug?

J.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Re: Bug in SDCC code generation?

Post by dom »

It might be a rules bug? Might be worth dropping the optimisation level to see if it still comes through.

We're in the middle of trying to get onto a stable/released version of sdcc so if you can it might be worth raising this as an issue on GitHub so it can be tracked with the other issues.
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Bug in SDCC code generation?

Post by jorgegv »

dom wrote: Sat Feb 19, 2022 11:36 am It might be a rules bug? Might be worth dropping the optimisation level to see if it still comes through.
I was compiling with -SO3 --opt-code-size. I have removed them and still the error is the same.
dom wrote: Sat Feb 19, 2022 11:36 am We're in the middle of trying to get onto a stable/released version of sdcc so if you can it might be worth raising this as an issue on GitHub so it can be tracked with the other issues.
I'll try to generate a minimum code snippet that triggers the failure and will open an issue.
User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Bug in SDCC code generation?

Post by jorgegv »

User avatar
jorgegv
Well known member
Posts: 287
Joined: Wed Nov 18, 2020 5:08 pm

Re: Bug in SDCC code generation?

Post by jorgegv »

It looks like it was finally a real bug, it's has been patched in upstream SDCC and it seems it will be included in upcoming Z88DK release. Thanks to all the masters here and there. :-)
Post Reply