Found couple of bugs

Bug reports (if you don't/won't have a Github account)
Post Reply
zx64
New member
Posts: 6
Joined: Thu Apr 29, 2021 2:45 am

Found couple of bugs

Post by zx64 »

Bug 1

Code: Select all

#include <stdio.h>

typedef unsigned long   uint32;
typedef unsigned short  addr16;
typedef unsigned short  uint16;
typedef unsigned char   uint8;

uint8* stack = 0;
addr16 stackTop = 0;

static uint32 stackPeek() {
    uint8* location = stack + stackTop;
    return *((uint32*)location);
}

static uint32 stackPop() {
    uint32 value = stackPeek();
    stackTop += 4;
    return value;
}

void main() {
    stackPop();
    printf ("%x ", stackTop);
    stackPop();
    printf ("%x ", stackTop);
    stackPop();
    printf ("%x ", stackTop);
    stackPop();
    printf ("%x ", stackTop);
    stackPop();
    printf ("%x ", stackTop);
}
Compiled it with latest build (z88dk-win32-20210428-31efe20-18269)

Code: Select all

zcc +zx -vn -clib=sdcc_iy -startup=0 Bug1.c -o bug -create-app
Expected to see "4 8 c 10 14" but got "404 808 c0c 1010 1414"

Note: using --max-allocs-per-node0 options fixes the problem
zx64
New member
Posts: 6
Joined: Thu Apr 29, 2021 2:45 am

Re: Found couple of bugs

Post by zx64 »

Bug 2

Code: Select all

#include <stdio.h>

typedef unsigned long   uint32;
typedef unsigned short  addr16;
typedef unsigned short  uint16;
typedef unsigned char   uint8;

uint8* memory = 0;

void memWrite(uint32 sectorNumber){
    uint16 value = 200;
    uint32* byte51202 = (uint32*)(memory + 51202);
    *byte51202 = sectorNumber;
    memory[51210]=100;
    memory[51212]=value;
}

void main() {
    memWrite(0);
    printf ("%u ", memory[51210]);
    printf ("%u ", memory[51212]);
}
Compiled it with latest build (z88dk-win32-20210428-31efe20-18269)

Code: Select all

zcc +zx -vn -clib=sdcc_iy -startup=0 Bug2.c -o bug -create-app
Expected to see "100 200" but got "0 0"

Using --max-allocs-per-node0 option did not help, output was "0 200"
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: Found couple of bugs

Post by dom »

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

Re: Found couple of bugs

Post by dom »

It looks like both are --reserve-regs-iy bugs, so you could switch to sdcc_ix instead of sdcc_iy.

I've verified that the first issue is fixed (probably a handful of days ago) in upstream sdcc so we'll need to do another sdcc upgrade. The second one probably is as well, I just haven't had time to check.
zx64
New member
Posts: 6
Joined: Thu Apr 29, 2021 2:45 am

Re: Found couple of bugs

Post by zx64 »

Thanks it works indeed. I will use it as a workaround for now
Post Reply