I finally lost patience with the terrible C compiler on the Tek4404 and am now porting (an old) version of gcc. Its proving challenging because the native compiler just explodes with anything but the most trivial expressions - and compiling compilers generates non-trivial expressions
I spent last week “pre-masticating” files on a Mac so all includes were resolved into a single file and replaced the Tek4404 cpp with a passthru since it frequently core dumped just reading thru the file…
But after rewriting / strength reducing lots of the large expressions and finally getting it to compile, the code the native compiler produces is wrong and it crashes anyway…
I even tried pasting in an enormous expression into ChatGPT and asked for simple K&R and it came out with something that “looked” sane… But it failed to compile.
My latest attack is to use gcc-cross-m68k on my Mac to emit assembler that I can hopefully get translated on the Tek4404 without the assembler losing the will to live also…
So, if there are others walking this road, be great to chat!
I’d forgotten how big the expressions generated by compiling compilers do get… see below.
if (((((y)->code) == LABEL_REF || ((y)->code) == SYMBOL_REF || ((y)->code) == CONST_INT || ((y)->code) == CONST) || (((y)->code) == REG && ((((y)->fld[0].rtint) & ~027) != 0)) || ((((y)->code) == PRE_DEC || ((y)->code) == POST_INC) && (((((y)->fld[0].rtx))->code) == REG) && ((((((y)->fld[0].rtx))->fld[0].rtint) & ~027) != 0)) || (((y)->code) == PLUS && (((((y)->fld[0].rtx))->code) == REG) && ((((((y)->fld[0].rtx))->fld[0].rtint) & ~027) != 0) && ((((y)->fld[1].rtx))->code) == CONST_INT && ((unsigned) ((((y)->fld[1].rtx))->fld[0].rtint) + 0x8000) < 0x10000))) goto win; }; { { if (((y)->code) == PLUS && (((((((y)->fld[0].rtx))->code) == REG && ((((((y)->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((y)->fld[0].rtx))->code) == SIGN_EXTEND && ((((((y)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((y)->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((y)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((y)->fld[0].rtx))->code) == MULT && ((((((((y)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((y)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((y)->fld[0].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((y)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((y)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((y)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((y)->fld[0].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((y)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((y)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((y)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((y)->fld[1].rtx))->code) == LABEL_REF) goto win; if (((((y)->fld[1].rtx))->code) == REG && ((((((y)->fld[1].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } if (((y)->code) == PLUS && (((((((y)->fld[1].rtx))->code) == REG && ((((((y)->fld[1].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((y)->fld[1].rtx))->code) == SIGN_EXTEND && ((((((y)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((y)->fld[1].rtx))->fld[0].rtx))->mode) == HImode && ((((((((y)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((y)->fld[1].rtx))->code) == MULT && ((((((((y)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((((y)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((y)->fld[1].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((y)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((y)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((y)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((y)->fld[1].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((y)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((y)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((y)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((y)->fld[0].rtx))->code) == LABEL_REF) goto win; if (((((y)->fld[0].rtx))->code) == REG && ((((((y)->fld[0].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } }; if (((y)->code) == PLUS) { if (((((y)->fld[1].rtx))->code) == CONST_INT && (unsigned) ((((y)->fld[1].rtx))->fld[0].rtint) + 0x80 < 0x100) { rtx go_temp = ((y)->fld[0].rtx); { if (((go_temp)->code) == PLUS && (((((((go_temp)->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((go_temp)->fld[0].rtx))->code) == SIGN_EXTEND && ((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((go_temp)->fld[0].rtx))->code) == MULT && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((go_temp)->fld[1].rtx))->code) == LABEL_REF) goto win; if (((((go_temp)->fld[1].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } if (((go_temp)->code) == PLUS && (((((((go_temp)->fld[1].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((go_temp)->fld[1].rtx))->code) == SIGN_EXTEND && ((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtx))->mode) == HImode && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((go_temp)->fld[1].rtx))->code) == MULT && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((go_temp)->fld[0].rtx))->code) == LABEL_REF) goto win; if (((((go_temp)->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } }; } if (((((y)->fld[0].rtx))->code) == CONST_INT && (unsigned) ((((y)->fld[0].rtx))->fld[0].rtint) + 0x80 < 0x100) { rtx go_temp = ((y)->fld[1].rtx); { if (((go_temp)->code) == PLUS && (((((((go_temp)->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((go_temp)->fld[0].rtx))->code) == SIGN_EXTEND && ((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((go_temp)->fld[0].rtx))->code) == MULT && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((go_temp)->fld[0].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((go_temp)->fld[0].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((go_temp)->fld[0].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((go_temp)->fld[1].rtx))->code) == LABEL_REF) goto win; if (((((go_temp)->fld[1].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } if (((go_temp)->code) == PLUS && (((((((go_temp)->fld[1].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((go_temp)->fld[1].rtx))->code) == SIGN_EXTEND && ((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[1].rtx))->fld[0].rtx))->mode) == HImode && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) || ((target_flags & 1) && ((((go_temp)->fld[1].rtx))->code) == MULT && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8)) || (((((((go_temp)->fld[1].rtx))->fld[0].rtx))->code) == SIGN_EXTEND && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->code) == REG && ((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->mode) == HImode && ((((((((((go_temp)->fld[1].rtx))->fld[0].rtx))->fld[0].rtx))->fld[0].rtint) ^ 020) >= 8))) && ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->code) == CONST_INT && (((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 2 || ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 4 || ((((((go_temp)->fld[1].rtx))->fld[1].rtx))->fld[0].rtint) == 8)))) { { if (((((go_temp)->fld[0].rtx))->code) == LABEL_REF) goto win; if (((((go_temp)->fld[0].rtx))->code) == REG && ((((((go_temp)->fld[0].rtx))->fld[0].rtint) & ~027) != 0)) goto win; }; } }; } } }; };
** FATAL ERROR: Internal table overflow - “switch” item count.