コード例 #1
0
ファイル: test_decode.py プロジェクト: moreati/revelation
def test_bit16_imm():
    instr = Instruction(opcode_factory.bitr16_immediate(rd=0b110, rn=0b101, imm=0b11111),
                        None)
    assert instr.imm5 == 0b11111
    assert instr.rd == 0b110
    assert instr.rn == 0b101
    instr = Instruction(opcode_factory.lsr16_immediate(rd=0, rn=0, imm=0b01011),
                        None)
    assert instr.imm5 == 0b01011
コード例 #2
0
def test_execute_logical_shift_right_imm(rn, imm, is16bit):
    rd = 2
    state = new_state(rf0=trim_32(rn))
    instr = (opcode_factory.lsr16_immediate(rd=rd, rn=0, imm=imm) if is16bit
             else opcode_factory.lsr32_immediate(rd=rd, rn=0, imm=imm))
    name, executefn = decode(instr)
    executefn(state, Instruction(instr, None))
    expected_state = StateChecker(AZ=(False if rn < 0 else True), # 1 >> 5 == 0
                                  AV=0, AC=0,
                                  pc=((2 if is16bit else 4) + RESET_ADDR),
                                  rf2=(0b1111 if rn < 0 else 0))
    expected_state.check(state)
コード例 #3
0
ファイル: test_decode.py プロジェクト: moreati/revelation
 ('add16',       opcode_factory.add16_immediate(rd=1, rn=0, imm=0b0101)),
 ('sub32',       opcode_factory.sub32_immediate(rd=1, rn=0, imm=0b01010101010)),
 ('sub16',       opcode_factory.sub16_immediate(rd=1, rn=0, imm=0b0101)),
 ('and32',       opcode_factory.and32(rd=1, rn=1, rm=1)),
 ('and16',       opcode_factory.and16(rd=1, rn=1, rm=1)),
 ('orr32',       opcode_factory.orr32(rd=1, rn=1, rm=1)),
 ('orr16',       opcode_factory.orr16(rd=1, rn=1, rm=1)),
 ('eor32',       opcode_factory.eor32(rd=1, rn=1, rm=1)),
 ('eor16',       opcode_factory.eor16(rd=1, rn=1, rm=1)),
 ('asr32',       opcode_factory.asr32(rd=1, rn=1, rm=1)),
 ('asr16',       opcode_factory.asr16(rd=1, rn=1, rm=1)),
 ('lsr32',       opcode_factory.lsr32(rd=1, rn=1, rm=1)),
 ('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)),