MSX sccz80 - unsigned char array

Bug reports (if you don't/won't have a Github account)
Post Reply
Rogerup
New member
Posts: 2
Joined: Sat Mar 30, 2019 12:20 am

MSX sccz80 - unsigned char array

Post 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
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post 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.
Timmy
Well known member
Posts: 392
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

You mean he should use the latest nightly version instead of those 'official' versions, right?
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Post 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.
Post Reply