Page 1 of 1

MSX sccz80 - unsigned char array

Posted: Sat May 18, 2019 1:47 pm
by Rogerup

Code: Select all

void main()
{
    unsigned char tab[8];
    unsigned char obj;

    obj = 6;
    tab[4] = obj;
    if (tab[4] != obj)
        while(1);
}
This code doesn't return if compiled with sccz80 (Most Recent Official Release currently v1.99C dated 19 Jan 2019)

If compiled with sdcc it returns.
If compiled with char (removed unsigned) it returns.

Asm generated:
._main
push bc
push bc
push bc
push bc
dec sp
ld hl,0 ;const
add hl,sp
ld (hl),#(6 % 256 % 256)
ld hl,5 ;const
add hl,sp
ex de,hl
ld hl,2 ;const
add hl,sp
ld a,(hl)
ld (de),a
ld hl,5 ;const
add hl,sp
ld e,(hl)
ld d,0
pop hl
push hl
ld h,0
call l_ne
jp nc,i_2
.i_3
jp i_3
.i_4
.i_2
inc sp
pop bc
pop bc
pop bc
pop bc
ret

Posted: Sun May 19, 2019 9:18 pm
by dom
Thanks for the report.

I think that this is issue: https://github.com/z88dk/z88dk/issues/1126 - basically an issue in the optimisation rules that resulted in the wrong stack offset being calculated and hence the wrong value being tested against.

Posted: Tue May 21, 2019 8:04 pm
by Timmy
You mean he should use the latest nightly version instead of those 'official' versions, right?

Posted: Wed May 22, 2019 9:19 am
by dom
For the moment yes. Nightly versions will always have the latest fixes. This fix could be manually applied, but the rules files are a bit picky.

There's a plan to do another release this summer which will have the latest SDCC version and the new IEEE maths library.