Example #1
0
 def test_cpu_state__ix_plus_n_2(self):
     code = """
     ld a, (ix + 1)
     """
     self._eval(code)
     self.assertTrue(helpers.is_unknown8(self.cpu_state.mem['ix+1']))
     self.assertEqual(self.cpu_state.mem['ix+1'], self.regs['a'])
Example #2
0
 def test_cpu_state_ld_a_unknown(self):
     code = """
     ld a, (_N)
     """
     self._eval(code)
     self.assertTrue(helpers.is_unknown8(self.regs['a']))
     self.assertEqual(self.regs['a'], cpustate.get_L_from_unknown_value(self.cpu_state.mem['_N']))
Example #3
0
 def test_hl_is_half_known(self):
     code = """
     ld h, 0
     """
     self._eval(code)
     h, l = self.regs['hl'].split(helpers.HL_SEP)
     self.assertTrue(helpers.is_number(h))
     self.assertTrue(helpers.is_unknown8(l))
     self.assertEqual(self.regs['h'], '0')
Example #4
0
 def test_cpu_state__ix_plus_n(self):
     code = """
     ld (ix + 1), _a
     ld (IY - 2), 259
     """
     self._eval(code)
     self.assertTrue(helpers.is_unknown8(self.cpu_state.mem['ix+1']))
     self.assertEqual(self.cpu_state.mem['iy-2'], str(259 & 0xFF))
     self.assertTrue(all((x[:2], x[2], x[3:]) in self.cpu_state.ix_ptr for x in self.cpu_state.mem.keys()))
Example #5
0
def test_H16_val():
    """ Test high value of an integer or unknown val is ok
    """
    # For an unknown 8 bit val, the high part is always 0
    assert helpers.is_unknown8(helpers.HI16_val(None))
    tmp8 = helpers.new_tmp_val()
    hi16 = helpers.HI16_val(tmp8)
    assert hi16 == '0'

    # For integers, it's just the high part
    assert helpers.HI16_val('255') == '0'
    assert helpers.HI16_val('256') == '1'

    # For normal unknowns16, the high part must be returned
    tmp16 = helpers.new_tmp_val16()
    assert helpers.HI16_val(tmp16) == tmp16.split(helpers.HL_SEP)[0]
    assert helpers.is_unknown8(helpers.HI16_val(tmp16))
    assert helpers.is_unknown8(
        helpers.HI16_val('_unknown'))  # An unknown expression
Example #6
0
 def test_xor_a_ld_n_a(self):
     code = """
     xor a
     ld (_push), a
     """
     self._eval(code)
     self.assertEqual(self.regs['a'], '0')
     self.assertFalse(helpers.is_unknown8(self.regs['a']))
     self.assertEqual(self.cpu_state.C, 0)
     self.assertEqual(self.cpu_state.Z, 1)
Example #7
0
 def test_in_a_c(self):
     code = """
     xor a
     in a, (c)
     """
     self._eval(code)
     self.assertNotEqual(self.regs['a'], '0')
     self.assertTrue(helpers.is_unknown8(self.regs['a']))
     self.assertEqual(self.cpu_state.C, 0)
     self.assertEqual(self.cpu_state.Z, 1)