             0xF0, 0xA0, // LD A, ($F0)
             0x0E, 0xA1, // LD C, $A1
             0xF2,       // LD A, (C)
-            
+
             0x3E, 0xAA, // LD A, $AA
             0xEA, 0xA0, 0xDF, // LD ($DFA0), A
             0x3E, 0xBB, // LD A, $BB

            0x78,       // LD A, B  (4 cycles)
            0x06, 0x20  // LD B, 20 (8 cycles)
        ]
        
        // Load program into RAM
        for (offset, byte) in program.enumerated() {
            cpu.memory.write(0xC000 + Address(offset), byte)
        }
        
        // Start program execution from RAM
        cpu.PC = 0xC000
        
        cpu.step()
        XCTAssert(cpu.B == UInt8(0x10))
        cpu.step()
        XCTAssert(cpu.A == UInt8(0x10))
        cpu.step()
        XCTAssert(cpu.B == UInt8(0x20))
        
        XCTAssert(cpu.cycle == 20)
    }
    
    func test8BitLoads() {
        var cpu = CPU(memory: Memory())
        let program: [UInt8] = [

            0xC1,             // POP BC
            0xD1,             // POP DE
            0xE1,             // POP HL

            0x08, 0x00, 0xD0, // LD ($D000), SP
            0x21, 0x00, 0xD0, // LD HL, $D000
            0x2A,             // LD A, (HL+)
            0x2A,             // LD A, (HL+)
        ]


        // Load program into RAM
        for (offset, byte) in program.enumerated() {
            cpu.memory.write(0xC000 + Address(offset), byte)
        }

        // Start program execution from RAM
        cpu.PC = 0xC000

        cpu.step()
        XCTAssertEqual(cpu.BC, 0x0123)
        XCTAssertEqual(cpu.B, 0x01)
        XCTAssertEqual(cpu.C, 0x23)

        cpu.step()
        XCTAssertEqual(cpu.DE, 0x4567)
        XCTAssertEqual(cpu.D, 0x45)
        XCTAssertEqual(cpu.E, 0x67)

        cpu.step()
        XCTAssertEqual(cpu.HL, 0x89AB)
        XCTAssertEqual(cpu.H, 0x89)
        XCTAssertEqual(cpu.L, 0xAB)

        cpu.step()
        XCTAssertEqual(cpu.SP, 0xCDEF)

        2.times { cpu.step() }
        XCTAssertEqual(cpu.SP, 0xFFEF)

        cpu.step()
        XCTAssertEqual(cpu.HL, 0xFFDF)
        XCTAssertEqual(cpu.CFlag, true)
        XCTAssertEqual(cpu.HFlag, true)
        cpu.step()
        XCTAssertEqual(cpu.HL, 0xFFFF)
        XCTAssertEqual(cpu.CFlag, false)
        XCTAssertEqual(cpu.HFlag, true)

        11.times { cpu.step() }
        XCTAssertEqual(cpu.AF, 0xCDEF)
        XCTAssertEqual(cpu.BC, 0x89AB)
        XCTAssertEqual(cpu.DE, 0x4567)
        XCTAssertEqual(cpu.HL, 0x0123)

        3.times { cpu.step() }
        XCTAssertEqual(cpu.A, cpu.SP.offset)
        cpu.step()
        XCTAssertEqual(cpu.A, cpu.SP.page)
    }

    func testADD() {
        var cpu = CPU(memory: Memory())
        let program: [UInt8] = [
            0x31, 0xFF, 0xFF, // LD SP, $FFFF

            0x3E, 0x10, // LD A $10
            0x06, 0x01, // LD B $01
            0x0E, 0x02, // LD C $02
