Menu

#2933 FATAL Compiler Internal Error in file z80/ralloc.c

closed-out-of-date
None
Z80
5
2023-01-26
2019-09-21
No

It is a complex error, I simpified the source as I can. Present in current build of SDCC.

#define __ASHL(x, n, t) ((t)(x)<<(n))

extern void Laser2_PTBL (signed char col, signed char row, unsigned char spn);

static int yy;

static void Sub_9300 (void)
{
    unsigned char i, j, n, _for__84, _for__83; int a;
    j = 0;
    _for__84 = 3;
    do {
        i = 0;
        _for__83 = 9;
        do {
            n = i;
            if (j == 1) {
                n = 8 - i;
            }
            a = (int)(j * 9 + i) * 250;

            if (yy > a) {
                Laser2_PTBL(26 - n * 3, 19 - __ASHL(j, 2, unsigned char), 115);
            }
            i += 1;
        } while (--_for__83);
        j += 1;
    } while (--_for__84);
}

sdcc Durak.c -mz80 --code-loc 32832 --data-loc 63488 --oldralloc --reserve-regs-iy

(z80.lib must be available)

1 Attachments

Related

Wiki: NGI0-Entrust-SDCC

Discussion

  • Oleg N. Cher

    Oleg N. Cher - 2019-09-21

    Another similar error was presents in SDCC 3.6.0 #9615
    but fixed in SDCC 3.9.3 #11378 (MINGW32)

    Perhaps this info will be helpful.

    I'm sorry that there is so much code, but if I remove even a line, the error disappears.

    typedef signed char BYTE;
    typedef unsigned char BOOLEAN;
    
    typedef
        struct Durak_Card { BYTE suit, rank; } Durak_Card;
    
    typedef
        Durak_Card Durak_Cards[37];
    
    static int Durak_man, Durak_cpu, Durak_min, Durak_rate, Durak_time, Durak_maxTime, Durak_gm;
    static BYTE Durak_s2, Durak_pri;
    static BOOLEAN Durak_took;
    static BYTE Durak_skill, Durak_skillMin, Durak_border, Durak_needSort;
    static BOOLEAN Durak_sort;
    static BYTE Durak_menuPtr, Durak_cardPtr, Durak_cardPtrStep;
    static Durak_Cards Durak_pack;
    static BYTE Durak_packN;
    static Durak_Cards Durak_hand[2];
    static BYTE Durak_handN[2];
    static Durak_Card Durak_desk[13];
    static BYTE Durak_deskN, Durak_trump, Durak_badSuit;
    
    static BYTE Durak_nn;
    
    static BOOLEAN Durak_CanBeatBy (Durak_Card *beatCard);
    static void Durak_DrawEyes (BYTE phase);
    
    static void Durak_CpuDefends (void)
    {
        BYTE i, j, phase;
        int ms, z;
        BYTE min, _for__18, _for__17, _for__16, _for__15;
        if (Durak_took) {
            phase = 0;
        } else {
            phase = 2;
            min = -1;
            ms = 8000;
            i = 1;
            _for__18 = Durak_handN[1];
            if (i <= _for__18) {
                _for__18 = (_for__18 - i) + 1;
                do {
                    phase = 3 - phase;
                    if (!Durak_CanBeatBy(&Durak_hand[1][i])) {
                        Durak_DrawEyes(phase);
                    } else {
                        z = Durak_hand[1][i].rank * 10;
                        if (Durak_hand[1][i].suit == Durak_trump) {
                            z += 123;
                        }
                        if ((Durak_skill != 4 && (unsigned char)Durak_packN > 0x01) || Durak_skill == 1) {
                            j = i;
                            _for__17 = Durak_handN[1];
                            if (j <= _for__17) {
                                _for__17 = (_for__17 - j) + 1;
                                do {
                                    if (Durak_hand[1][j].rank == Durak_hand[1][i].rank) {
                                        z -= 15;
                                    }
                                    j += 1;
                                } while (--_for__17);
                            }
                            j = 1;
                            _for__16 = Durak_deskN;
    
                        }
                    }
                    phase = 1;
                    Durak_took = 1;
                    Durak_nn = Durak_handN[1];
                    i += 1;
                } while (--_for__18);
            }
        }
        Durak_deskN += 1;
        Durak_desk[Durak_deskN].rank = 0;
    }
    

    sdcc Durak.c -mz80 --code-loc 32832 --data-loc 63488 --oldralloc --reserve-regs-iy

     
  • Philipp Klaus Krause

    • status: open --> closed-out-of-date
    • assigned_to: Philipp Klaus Krause
    • Category: other --> Z80
     
  • Philipp Klaus Krause

    Looks like a bug in the old register allocator, which has been removed for z80.

     

Log in to post a comment.

MongoDB Logo MongoDB