 extern byte ram[];
 extern byte pia[];
 
-uint8_t memRead(uint16_t addr) {
+#define ADDR ((addrh << 8) | addrl)
+
+uint8_t memRead(const uint8_t addrh, const uint8_t addrl) {
+  const uint16_t addr = ADDR;
   uint8_t val;
   switch (addr >> 12) {
     default:

    if (PINB & _BV(PB2)) {
      // read cycle
      DDRL = 0xff;
      PORTL = memRead((addrh << 8) | addrl);
    } else {
      // write cycle
      DDRL = 0x00;
      PORTL = 0;
      memWrite((addrh << 8) | addrl, PINL);
    }
  }
}

byte ram[0x1000];
byte pia[0x14];

void printAddr(const uint16_t addr, const uint8_t col, const uint8_t row) {
  lcd.setCursor(col, row);
  lcd.print((addr >> 12) & 0x0f, HEX);
  lcd.print((addr >> 8) & 0x0f, HEX);
