Monthly Archives: January 2016

Testing 1, 2, 3…

I borrowed some bits from my 6502 GCC port to wire up the instruction-set simulator to GCC’s testsuite: there may be (probably are!) bugs in all of the simulator, binutils and GCC, but PASSes will mean they are all consistent with each other, which is something at least. I also fixed linking so it maps sections to segments (aka program headers) properly, which was a 1-line fix, but as ever, the hard part was figuring out why it wasn’t working to start with.

In GCC proper, register elimination (replacing offset frame pointer accesses with offset stack pointer accesses, etc.) is now working somewhat properly: it was broken for a long time because of a preprocessor misfeature: it turns out if you have something like,

#include <stdio.h>

enum bla {


int main(int argc, char* argv[])
  printf ("Boom!\n");
  printf ("This is what you might expect to execute\n");
  return 0;

Then it compiles without warning, but the “Boom!” line is executed — the undefined identifiers FIRST and SECOND are both replaced with 0, since the preprocessor knows nothing about the enum. Anyway, in the real code, this meant that (via a similar #if condition) eliminations happened to the wrong register, leading to much confusion!

Oh, and (update) here are the initial results:

                === gcc Summary ===

# of expected passes            46281
# of unexpected failures        9307
# of unexpected successes       1
# of expected failures          94
# of unresolved testcases       7623
# of unsupported tests          1556

Hello world

“Hello world” is compiling and linking, more or less, but (predictably) doesn’t work, at least with the instruction-set simulator. Hmm, seems like debugging this might be hard!

My table is tidy now due to some unscheduled cleaning-up time. It might get replaced with a new desk soon!