public char get(int addr) {
    if (addr < 65536)
      return ram[addr & 0xFFFF];
    if (addr < 65544)
      return registers[addr & 0x7];
    if (addr >= 131072)
      return (char)addr;
    if (addr == 65544)
      return sp;
    if (addr == 65545)
      return pc;
    if (addr == 65552) {
      return ex;
    }
    throw new IllegalStateException("Illegal address " + Integer.toHexString(addr) + "! How did you manage that!?");
  }