     }
   } else if address >= 0xA000 and address <= 0xBFFF {
     // External RAM
-    let eram_size = rom_get_ext_ram_size();
-    let offset = address - 0xA000;
+    let eram_size = uint64(rom_get_ext_ram_size());
+    let offset = uint64(address) - 0xA000;
     if mmu_mbc1_ram_enable and offset < eram_size {
-      *((eram + (mmu_mbc1_ram_bank * 0x2000)) + offset) = value;
+      *((eram + (uint64(mmu_mbc1_ram_bank) * 0x2000)) + offset) = value;
     }
   } else {
     // Unhandled

def cpu_step(): uint8 {
  CYCLES = 0;

  // IF HALT; just return 4 (cycles)
  if HALT {
    if (IE & IF & 0x1F) == 0 {

  flag_set(FLAG_Z, false);
}

// [10] STOP
def op_10() {
  cpu_stop = true;
}

// [11] LD DE, nn
def op_11() {
