def test_mov_special_registers(): # Note that in the MOV 'special' instructions rd and rn are swapped. instr = Instruction(opcode_factory.movfs16(rn=0, rd='CONFIG'), '') assert instr.rd == 1 # 65 - 64 assert instr.rn == 0 instr = Instruction(opcode_factory.movfs32(rn=0, rd='pc'), '') assert instr.rd == 3 # 67 - 64 assert instr.rn == 0 instr = Instruction(opcode_factory.movts16(rn='CONFIG', rd=0), '') assert instr.rd == 0 assert instr.rn == 1 # 65 - 64 instr = Instruction(opcode_factory.movts32(rn='pc', rd=0), '') assert instr.rd == 0 assert instr.rn == 3 # 67 -64
def test_execute_mov_special(is16bit, is_from): # Note that in the MOV 'special' instructions rd and rn are swapped. state = new_state(rf0=5, rfCONFIG=7) if is_from and is16bit: instr = opcode_factory.movfs16(rn=0, rd='CONFIG') expected_state = StateChecker(pc=(2 + RESET_ADDR), rf0=7, rfCONFIG=7) elif is_from and (not is16bit): instr = opcode_factory.movfs32(rn=0, rd='CONFIG') expected_state = StateChecker(pc=(4 + RESET_ADDR), rf0=7, rfCONFIG=7) elif (not is_from) and is16bit: instr = opcode_factory.movts16(rn='CONFIG', rd=0) expected_state = StateChecker(pc=(2 + RESET_ADDR), rf0=5, rfCONFIG=5) elif (not is_from) and (not is16bit): instr = opcode_factory.movts32(rn='CONFIG', rd=0) expected_state = StateChecker(pc=(4 + RESET_ADDR), rf0=5, rfCONFIG=5) name, executefn = decode(instr) executefn(state, Instruction(instr, None)) expected_state.check(state)
('fix16', opcode_factory.fix16(rd=1, rn=0, rm=0)), ('fabs16', opcode_factory.fabs16(rd=1, rn=0, rm=0)), ('fadd32', opcode_factory.fadd32(rd=1, rn=0, rm=0)), ('fsub32', opcode_factory.fsub32(rd=1, rn=0, rm=0)), ('fmul32', opcode_factory.fmul32(rd=1, rn=0, rm=0)), ('fmadd32', opcode_factory.fmadd32(rd=1, rn=0, rm=0)), ('fmsub32', opcode_factory.fmsub32(rd=1, rn=0, rm=0)), ('float32', opcode_factory.float32(rd=1, rn=0, rm=0)), ('fix32', opcode_factory.fix32(rd=1, rn=0, rm=0)), ('fabs32', opcode_factory.fabs32(rd=1, rn=0, rm=0)), ('movcond32', opcode_factory.movcond32(condition=0b0000, rd=0, rn=0)), ('movcond16', opcode_factory.movcond16(condition=0b0000, rd=0, rn=0)), ('movtimm32', opcode_factory.movtimm32(rd=0b1111, imm=0)), ('movimm32', opcode_factory.movimm32(rd=0b1111, imm=0)), ('movimm16', opcode_factory.movimm16(rd=0b1111, imm=0)), ('movfs32', opcode_factory.movfs32(rn=0b110, rd='IRET')), ('movfs16', opcode_factory.movfs16(rn=0b110, rd='IRET')), ('movts32', opcode_factory.movts32(rn='IRET', rd=0b011)), ('movts16', opcode_factory.movts16(rn='IRET', rd=0)), ('gie16', opcode_factory.gie16()), ('gid16', opcode_factory.gid16()), ('nop16', opcode_factory.nop16()), ('idle16', opcode_factory.idle16()), ('bkpt16', opcode_factory.bkpt16()), ('mbkpt16', opcode_factory.mbkpt16()), ('sync16', opcode_factory.sync16()), ('rti16', opcode_factory.rti16()), ('wand16', opcode_factory.wand16()), ('trap16', opcode_factory.trap16(trap=0b111111)), ('unimpl', opcode_factory.unimpl()), ])