def testMOVM(self, chip):
     sources = "BCDEHLMA"
     for i, src in enumerate(sources):
         chip.reset()
         chip.memory[0] = 0x70 + i
         if src == "M":
             self.testHLT(chip)
         else:
             chip.registers["H"], chip.registers["L"], chip.registers[src] = 0x00, 0x01, 0x11
             address = Chip8080.make16bitWord(chip.registers["H"], chip.registers["L"])
             
             chip.runCode(chip.memory[0])
             assert chip.memory[address] == 0x11, "Memory write failed"
 def testINX(self, chip):
     opCodes = { 
         "B" : 0x03,
         "D" : 0x13,
         "H" : 0x23
     }
     for reg in opCodes:
         chip.reset()
         chip.memory[0] = opCodes[reg]
         chip.registers[reg] = 0x00
         chip.registers[chip.pairs[reg]] = 0x01
         
         
         initial = Chip8080.make16bitWord(chip.registers[reg], chip.registers[chip.pairs[reg]])
         chip.runCode(chip.memory[0])
         final = Chip8080.make16bitWord(chip.registers[reg], chip.registers[chip.pairs[reg]])
         
         assert final == (initial + 1) % 0x10000, "Increment failed."
         assert not chip.carry, "Carry flag should be zero"
         assert not chip.sign, "Sign flag should be zero"
         assert not chip.zero, "Zero flag should be zero"
         assert not chip.aux_carry, "AuxCarry flag should be zero"
         assert not chip.parity, "Parity flag should be zero"
 def testMOV(self, chip, dst, firstcode):
     sources = "BCDEHLMA"
     for i, src in enumerate(sources):
         chip.reset()
         opcode = firstcode + i
         chip.memory[0] = opcode
         if src == "M":
             chip.registers["H"], chip.registers["L"] = 0x00, 0x01
             address = Chip8080.make16bitWord(chip.registers["H"], chip.registers["L"])
             chip.memory[1] = 0x11
             value = chip.memory[address]
         else:
             chip.registers[src] = 0x11
             value = chip.registers[src]
             
         chip.runCode(chip.memory[0])
         assert chip.registers[dst] == value, "value not moved from " + src + " to " + dst +"correctly".format(src,dst)
 def testSTAX(self, chip):
     opCodes = { 
         "B" : 0x02,
         "D" : 0x12,
     }
     for reg in opCodes:
         chip.reset()
         chip.memory[0] = opCodes[reg]
         chip.registers["A"] = 0x55
         
         chip.registers[reg] = 0x01
         chip.registers[chip.pairs[reg]] = 0x00
         
         address = Chip8080.make16bitWord(chip.registers[reg], chip.registers[chip.pairs[reg]])
         chip.runCode(chip.memory[0])
         
         assert not chip.carry, "Carry flag should be zero"
         assert not chip.sign, "Sign flag should be zero"
         assert not chip.zero, "Zero flag should be zero"
         assert not chip.aux_carry, "AuxCarry flag should be zero"
         assert not chip.parity, "Parity flag should be zero"
         
         assert chip.memory[address] == chip.registers["A"], "Memory not written correctly"