Exemple #1
0
def test_bcond32():
    instructions = [(opcode_factory.sub32_immediate(rd=1, rn=0, imm=0b00000000101), 32),
                    (opcode_factory.bcond32(condition=0b0000, imm=0b000000000000000000000100), 32),
                    (opcode_factory.add32_immediate(rd=1, rn=0, imm=0b01010101010), 32),
                    (opcode_factory.bkpt16(), 16),
                    ]
    epiphany = MockEpiphany()
    epiphany.init_state(instructions, rf0=5)
    assert epiphany.state.running
    epiphany.run()
    expected_state = StateChecker(pc=(14 + RESET_ADDR), rf1=0)
    expected_state.check(epiphany.state)
    assert not epiphany.state.running
    epiphany.init_state(instructions, rf0=8)
    epiphany.run()
    expected_state = StateChecker(pc=(14 + RESET_ADDR), rf1=(8 + 0b01010101010))
    expected_state.check(epiphany.state)
    assert not epiphany.state.running
Exemple #2
0
def test_bcond32():
    instructions = [(opcode_factory.sub32_immediate(rd=1, rn=0, imm=0b00000000101), 32),
                    (opcode_factory.bcond32(condition=0b0000, imm=0b000000000000000000000100), 32),
                    (opcode_factory.add32_immediate(rd=1, rn=0, imm=0b01010101010), 32),
                    (opcode_factory.trap16(3), 16),
                    ]
    revelation = MockRevelation()
    revelation.init_state(instructions, rf0=5)
    assert revelation.states[0x808].running
    exit_code, ticks = revelation.run()
    expected_state = StateChecker(pc=(14 + RESET_ADDR), rf1=0)
    expected_state.check(revelation.states[0x808])
    assert EXIT_SUCCESS == exit_code
    assert len(instructions) - 1 == ticks
    assert not revelation.states[0x808].running
    revelation = MockRevelation()
    revelation.init_state(instructions, rf0=8)
    exit_code, ticks = revelation.run()
    expected_state = StateChecker(pc=(14 + RESET_ADDR), rf1=(8 + 0b01010101010))
    expected_state.check(revelation.states[0x808])
    assert EXIT_SUCCESS == exit_code
    assert len(instructions) == ticks
    assert not revelation.states[0x808].running
Exemple #3
0
 ('lsr16',       opcode_factory.lsr16(rd=1, rn=1, rm=1)),
 ('lsl32',       opcode_factory.lsl32(rd=1, rn=1, rm=1)),
 ('lsl16',       opcode_factory.lsl16(rd=1, rn=1, rm=1)),
 ('lsrimm16',    opcode_factory.lsr16_immediate(rd=1, rn=1, imm=1)),
 ('lslimm16',    opcode_factory.lsl16_immediate(rd=1, rn=1, imm=1)),
 ('asrimm16',    opcode_factory.asr16_immediate(rd=1, rn=1, imm=1)),
 ('bitrimm16',   opcode_factory.bitr16_immediate(rd=1, rn=1, imm=1)),
 ('lsrimm32',    opcode_factory.lsr32_immediate(rd=1, rn=1, imm=1)),
 ('lslimm32',    opcode_factory.lsl32_immediate(rd=1, rn=1, imm=1)),
 ('asrimm32',    opcode_factory.asr32_immediate(rd=1, rn=1, imm=1)),
 ('bitrimm32',   opcode_factory.bitr32_immediate(rd=1, rn=1, imm=1)),
 ('jr32',        opcode_factory.jr32(rn=0)),
 ('jr16',        opcode_factory.jr16(rn=0)),
 ('jalr32',      opcode_factory.jalr32(rn=0)),
 ('jalr16',      opcode_factory.jalr16(rn=0)),
 ('bcond32',     opcode_factory.bcond32(condition=0b1111, imm=0)),
 ('bcond16',     opcode_factory.bcond16(condition=0b1111, imm=0)),
 ('ldstrpmd32',  opcode_factory.ldstrpmd32(rd=1, rn=0, sub=1, imm=0b1010101010, bb=0b11, s=1)),
 ('ldstrdisp16', opcode_factory.ldstrdisp16(rd=1, rn=0, imm=0b010, bb=0b11, s=1)),
 ('ldstrdisp32', opcode_factory.ldstrdisp32(rd=1, rn=0, sub=1, imm=0b1010101010, bb=0b11, s=1)),
 ('ldstrpm16',   opcode_factory.ldstrpm16(rd=1, rn=0, rm=0, bb=0b11, s=1)),
 ('ldstrpm32',   opcode_factory.ldstrpm32(rd=1, rn=0, rm=0, sub=1, bb=0b11, s=1)),
 ('ldstrind16',  opcode_factory.ldstrind16(rd=1, rn=0, rm=0, bb=0b11, s=1)),
 ('ldstrind32',  opcode_factory.ldstrind32(rd=1, rn=0, rm=0, sub=1, bb=0b11, s=1)),
 ('testset32',   opcode_factory.testset32(rd=1, rn=0, rm=0, sub=1, bb=0b11)),
 ('fadd16',      opcode_factory.fadd16(rd=1, rn=0, rm=0)),
 ('fsub16',      opcode_factory.fsub16(rd=1, rn=0, rm=0)),
 ('fmul16',      opcode_factory.fmul16(rd=1, rn=0, rm=0)),
 ('fmadd16',     opcode_factory.fmadd16(rd=1, rn=0, rm=0)),
 ('fmsub16',     opcode_factory.fmsub16(rd=1, rn=0, rm=0)),
 ('float16',     opcode_factory.float16(rd=1, rn=0, rm=0)),