     case 0xd:
       if (LCD) printAddr(addr, 8, 1);
       if (LCD) printByte(val, 14, 1);
-      switch (addr & 0xff) {
+      switch (addrl) {
         default:
           pia[addr & 0xff] = val;
           break;

  }
}

void memWrite(const uint8_t addrh, const uint8_t addrl, const uint8_t val) {
  const uint16_t addr = ADDR;
  switch (addr >> 12) {
    default:
      // nothing in the address space ignore the write;

          }
          break;
        default:
          val = pia[addrl];
      }
      if (LCD) printAddr(addr, 8, 0);
      if (LCD) printByte(val, 14, 0);
