Page 1 of 1

Build error on x86_64

Posted: Mon Jul 14, 2008 5:56 am
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.


Code: Select all

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

Code: Select all

        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.