Build error on x86_64

Known bugs with 1.8
Post Reply
Char
New member
Posts: 6
Joined: Fri Apr 25, 2008 8:24 am

Build error on x86_64

Post by Char »

On AMD64, the long type is 64-bit, not 32, so sccz80 seems to generate huge numbers sometimes and fails to build the libs.

This is not the only error, only the first. But by patching it, all the others went away too.

libsrc/fcntl/z88/stat.c:

Code: Select all

#define JD0101970       2440588
time_t doepoch(long days, long sec)
{
        days-=JD0101970;        /* sub 1970 */
        days*=86400;            /* into seconds */
        return (days+sec);
}
stat.opt:

Code: Select all

._doepoch
        ld      hl,6    ;const
        add     hl,sp
        push    hl
        call    l_glong
        push    de
        push    hl
        ld      hl,49780        ;const
        ld      de,281474976710618
        call    l_long_add
z88asm does not like that huge constant.

I did not have too much time to dig after this, but found a possible workaround. It seems the problem appeares when casting a negative long to unsigned - all bits from 32 to 63 are 1. Hence, by adding

Code: Select all

        if (sizeof(unsigned long) > 4)
                val &= 0xffffffff;
at the beginning of vlongconst() and vlongconst_noalt() in codegen.c, I was able to build the libs. I am not at all sure this is the right fix, you should know better.

The output is now

Code: Select all

        ld      hl,49780        ;const
        ld      de,65498
        call    l_long_add
-2440588 translates to 0xffdac274 which is consistent with the new output.
Last edited by Char on Mon Jul 14, 2008 5:59 am, edited 1 time in total.
Post Reply