Exemplo n.º 1
0
 def _checkInterrupts(self):
     if self.iff1:
         self.halted = Bits.reset()
         self.iff1 = Bits.reset()
         self.iff2 = Bits.reset()
         self.ram[--self.SP] = Bits.limitTo8Bits(self.pc)
         self.ram[--self.SP] = self.pc >> 8
         self.R += 1
         if self.im == 0 or self.im == 1:
             self.PC = 0x0038
Exemplo n.º 2
0
 def _checkInterrupts(self):
     if self.iff1 and self.generateInterrupt:
         self.generateInterrupt = False
         self.halted = Bits.reset()
         self.iff1 = Bits.reset()
         self.iff2 = Bits.reset()
         self.ram[--self.SP] = Bits.limitTo8Bits(self.pc)
         self.ram[--self.SP] = self.pc >> 8
         self.R += 1
         if self.im == 0 or self.im == 1:
             self.PC = 0x0038
Exemplo n.º 3
0
    def inc8(cpu, opcode, logger):
        index = (opcode >> 3) & 7
        oldValue = cpu.regs[index]
        cpu.regs[index] = Bits.limitTo8Bits(cpu.regs[index] + 1)

        cpu.NFlag = Bits.reset()
        cpu.ZFlag = Bits.isZero(cpu.regs[index])
        cpu.HFlag = Bits.halfCarrySub(oldValue, cpu.regs[index])
        cpu.PVFlag = True if oldValue == 0x7f else False
        cpu.SFlag = Bits.isNegative(cpu.regs[index])

        cpu.m_cycles, cpu.t_states = 1, 4
        logger.info("INC {}".format(IndexToReg.translate8Bit(index)))
Exemplo n.º 4
0
 def AF(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[A] = value >> 8
     self.regs[F] = Bits.limitTo8Bits(value)
Exemplo n.º 5
0
 def A(self, value):
     self.regs[A] = Bits.limitTo8Bits(value)
Exemplo n.º 6
0
 def DE(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[D] = value >> 8
     self.regs[E] = Bits.limitTo8Bits(value)
Exemplo n.º 7
0
 def BC(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[B] = value >> 8
     self.regs[C] = Bits.limitTo8Bits(value)
Exemplo n.º 8
0
 def HL(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[H] = value >> 8
     self.regs[L] = Bits.limitTo8Bits(value)
Exemplo n.º 9
0
 def HL(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[H] = value >> 8
     self.regs[L] = Bits.limitTo8Bits(value)
Exemplo n.º 10
0
 def A(self, value):
     self.regs[A] = Bits.limitTo8Bits(value)
Exemplo n.º 11
0
 def E(self, value):
     self.regs[E] = Bits.limitTo8Bits(value)
Exemplo n.º 12
0
 def BC(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[B] = value >> 8
     self.regs[C] = Bits.limitTo8Bits(value)
Exemplo n.º 13
0
 def BCPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[B] = value >> 8
     self.regsPri[C] = Bits.limitTo8Bits(value)
Exemplo n.º 14
0
 def DEPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[D] = value >> 8
     self.regsPri[E] = Bits.limitTo8Bits(value)
Exemplo n.º 15
0
 def DE(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[D] = value >> 8
     self.regs[E] = Bits.limitTo8Bits(value)
Exemplo n.º 16
0
 def HLPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[H] = value >> 8
     self.regsPri[L] = Bits.limitTo8Bits(value)
Exemplo n.º 17
0
 def F(self, value):
     self.regs[F] = Bits.limitTo8Bits(value)
Exemplo n.º 18
0
 def R(self, value):
     self.r = Bits.limitTo8Bits(value)
Exemplo n.º 19
0
 def C(self, value):
     self.regs[C] = Bits.limitTo8Bits(value)
Exemplo n.º 20
0
 def __setitem__(self, addr, value):
     self.ram[addr] = Bits.limitTo8Bits(value)
Exemplo n.º 21
0
 def AF(self, value):
     value = Bits.limitTo16Bits(value)
     self.regs[A] = value >> 8
     self.regs[F] = Bits.limitTo8Bits(value)
Exemplo n.º 22
0
 def Z(self, value):
     self.z = Bits.limitTo8Bits(value)
Exemplo n.º 23
0
 def test_bits_limitTo8Bits_correctly_limits_value_to_8_bits(self):
     value = 0b1101010010
     self.assertEqual(0b1010010, Bits.limitTo8Bits(value))
Exemplo n.º 24
0
 def AFPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[A] = value >> 8
     self.regsPri[F] = Bits.limitTo8Bits(value)
Exemplo n.º 25
0
 def test_bits_limitTo8Bits_correctly_limits_value_to_8_bits(self):
     value = 0b1101010010
     self.assertEquals(0b1010010, Bits.limitTo8Bits(value))
Exemplo n.º 26
0
 def I(self, value):
     self.i = Bits.limitTo8Bits(value)
Exemplo n.º 27
0
 def HLPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[H] = value >> 8
     self.regsPri[L] = Bits.limitTo8Bits(value)
Exemplo n.º 28
0
 def WZ(self, value):
     self.W = Bits.limitTo8Bits(value >> 8)
     self.Z = Bits.limitTo8Bits(value)
Exemplo n.º 29
0
 def DEPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[D] = value >> 8
     self.regsPri[E] = Bits.limitTo8Bits(value)
Exemplo n.º 30
0
 def F(self, value):
     self.regs[F] = Bits.limitTo8Bits(value)
Exemplo n.º 31
0
 def BCPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[B] = value >> 8
     self.regsPri[C] = Bits.limitTo8Bits(value)
Exemplo n.º 32
0
 def B(self, value):
     self.regs[B] = Bits.limitTo8Bits(value)
Exemplo n.º 33
0
 def AFPrim(self, value):
     value = Bits.limitTo16Bits(value)
     self.regsPri[A] = value >> 8
     self.regsPri[F] = Bits.limitTo8Bits(value)
Exemplo n.º 34
0
 def C(self, value):
     self.regs[C] = Bits.limitTo8Bits(value)
Exemplo n.º 35
0
 def I(self, value):
     self.i = Bits.limitTo8Bits(value)
Exemplo n.º 36
0
 def D(self, value):
     self.regs[D] = Bits.limitTo8Bits(value)
Exemplo n.º 37
0
 def B(self, value):
     self.regs[B] = Bits.limitTo8Bits(value)
Exemplo n.º 38
0
 def E(self, value):
     self.regs[E] = Bits.limitTo8Bits(value)
Exemplo n.º 39
0
 def D(self, value):
     self.regs[D] = Bits.limitTo8Bits(value)
Exemplo n.º 40
0
 def H(self, value):
     self.regs[H] = Bits.limitTo8Bits(value)
Exemplo n.º 41
0
 def H(self, value):
     self.regs[H] = Bits.limitTo8Bits(value)
Exemplo n.º 42
0
 def L(self, value):
     self.regs[L] = Bits.limitTo8Bits(value)
Exemplo n.º 43
0
 def L(self, value):
     self.regs[L] = Bits.limitTo8Bits(value)
Exemplo n.º 44
0
 def R(self, value):
     self.r = Bits.limitTo8Bits(value)
Exemplo n.º 45
0
 def W(self, value):
     self.w = Bits.limitTo8Bits(value)
Exemplo n.º 46
0
 def __setitem__(self, addr, value):
     self.ram[addr] = Bits.limitTo8Bits(value)