def test_add_register_arguments(): instr = Instruction(opcode_factory.add32(rd=2, rn=1, rm=0), '') assert instr.rd == 2 assert instr.rn == 1 assert instr.rm == 0 instr = Instruction(opcode_factory.add32(rd=10, rn=9, rm=8), '') assert instr.rd == 2 + 8 assert instr.rn == 1 + 8 assert instr.rm == 0 + 8
from epiphany.isa import decode from epiphany.instruction import Instruction import opcode_factory import pytest @pytest.mark.parametrize('name,instr', [('add32', opcode_factory.add32(rd=0, rn=0, rm=0)), ('add16', opcode_factory.add16(rd=0, rn=0, rm=0)), ('add32', opcode_factory.add32(rd=1, rn=1, rm=1)), ('add16', opcode_factory.add16(rd=1, rn=1, rm=1)), ('sub32', opcode_factory.sub32(rd=0, rn=0, rm=0)), ('sub16', opcode_factory.sub16(rd=0, rn=0, rm=0)), ('sub32', opcode_factory.sub32(rd=1, rn=1, rm=1)), ('sub16', opcode_factory.sub16(rd=1, rn=1, rm=1)), ('add32', opcode_factory.add32_immediate(rd=1, rn=0, imm=0b01010101010)), ('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)),