Esempio n. 1
0
def machine_mockcpu_rw_reg_test():
    cpu = MockCPU()
    cpu.w_reg(REG_D0, 0xdeadbeef)
    assert cpu.r_reg(REG_D0) == 0xdeadbeef
    cpu.w_reg(REG_A6, 0xcafebabe)
    assert cpu.r_reg(REG_A6) == 0xcafebabe
    cpu.w_pc(0x123456)
    assert cpu.r_pc() == 0x123456
    cpu.w_sr(0x4711)
    assert cpu.r_sr() == 0x4711
    # invalid values
    with pytest.raises(OverflowError):
        cpu.w_reg(REG_D0, 0xdeafbeef12)
    with pytest.raises(OverflowError):
        cpu.w_reg(REG_D0, -1)
    with pytest.raises(TypeError):
        cpu.w_reg(REG_D0, 'hello, world!')
Esempio n. 2
0
def machine_mockcpu_rw_reg_test():
    cpu = MockCPU()
    cpu.w_reg(REG_D0, 0xDEADBEEF)
    assert cpu.r_reg(REG_D0) == 0xDEADBEEF
    cpu.w_reg(REG_A6, 0xCAFEBABE)
    assert cpu.r_reg(REG_A6) == 0xCAFEBABE
    cpu.w_pc(0x123456)
    assert cpu.r_pc() == 0x123456
    cpu.w_sr(0x4711)
    assert cpu.r_sr() == 0x4711
    # invalid values
    with pytest.raises(OverflowError):
        cpu.w_reg(REG_D0, 0xDEAFBEEF12)
    with pytest.raises(OverflowError):
        cpu.w_reg(REG_D0, -1)
    with pytest.raises(TypeError):
        cpu.w_reg(REG_D0, "hello, world!")
Esempio n. 3
0
def machine_mockcpu_rw_reg_test():
  cpu = MockCPU()
  cpu.w_reg(REG_D0, 0xdeadbeef)
  assert cpu.r_reg(REG_D0) == 0xdeadbeef
  cpu.w_reg(REG_A6, 0xcafebabe)
  assert cpu.r_reg(REG_A6) == 0xcafebabe
  cpu.w_pc(0x123456)
  assert cpu.r_pc() == 0x123456
  cpu.w_sr(0x4711)
  assert cpu.r_sr() == 0x4711
  # invalid values
  with pytest.raises(OverflowError):
    cpu.w_reg(REG_D0, 0xdeafbeef12)
  with pytest.raises(OverflowError):
    cpu.w_reg(REG_D0, -1)
  with pytest.raises(TypeError):
    cpu.w_reg(REG_D0, 'hello, world!')