z88dk forums

z80 Development Kit

You are not logged in.

#1 2019-05-18 14:47:58

Rogerup
New member
From: Brazil
Registered: 2019-03-30
Posts: 2
Website

MSX sccz80 - unsigned char array

Code:

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

Offline

 

#2 2019-05-19 22:18:08

dom
Administrator
Registered: 2007-07-15
Posts: 1337
Website

Re: MSX sccz80 - unsigned char array

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.

Offline

 

#3 2019-05-21 21:04:20

Timmy
Member
Registered: 2012-03-10
Posts: 92

Re: MSX sccz80 - unsigned char array

You mean he should use the latest nightly version instead of those 'official' versions, right?

Offline

 

#4 2019-05-22 10:19:56

dom
Administrator
Registered: 2007-07-15
Posts: 1337
Website

Re: MSX sccz80 - unsigned char array

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.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson