def test_xor3(self): """Test XOR3 execution""" # XOR3 Rn,Rm,imm16 exec_instruction("XOR3 R1, R2, 1", [(ExprId("R2", 32), ExprInt(0, 32))], [(ExprId("R1", 32), ExprInt(1, 32))])
def test_di(self): """Test DI execution""" # DI exec_instruction("DI", [(ExprId("PSW", 32), ExprInt(1, 32))], [(ExprId("PSW", 32), ExprInt(0, 32))])
def test_and3(self): """Test AND3 execution""" # AND3 Rn,Rm,imm16 exec_instruction("AND3 R1, R2, 0", [(ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R1", 32), ExprInt(0, 32))])
def test_dbreak(self): """Test DBREAK execution""" # DBREAK exec_instruction("DBREAK", [(ExprId("DBG", 32), ExprInt(0, 32))], [(ExprId("DBG", 32), ExprInt(0b10, 32))])
def test_ldc(self): """Test LDC execution""" # LDC Rn,imm5 exec_instruction("LDC R1, SAR", [(ExprId("SAR", 32), ExprInt(0x28, 32))], [(ExprId("R1", 32), ExprInt(0x28, 32))])
def test_xor(self): """Test XOR execution""" # XOR Rn, Rm exec_instruction("XOR R1, R2", [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))], [(ExprId("R1", 32), ExprInt(1, 32))])
def test_stc(self): """Test STC execution""" # STC Rn,imm5 exec_instruction("STC R1, SAR", [(ExprId("R1", 32), ExprInt(0x28, 32))], [(ExprId("SAR", 32), ExprInt(0x28, 32))])
def test_erepeat(self): """Test EREPEAT execution""" # EREPEAT disp17.align2 exec_instruction("EREPEAT 0x42", [(ExprId("PC", 32), ExprInt(0, 32))], [(ExprId("RPB", 32), ExprInt(4, 32)), (ExprId("RPE", 32), ExprInt(0x43, 32))])
def test_nor(self): """Test NOR execution""" # NOR Rn, Rm exec_instruction("NOR R1, R2", [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))], [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))])
def test_jsr(self): """Test JSR execution""" # JSR Rm exec_instruction("JSR R1", [(ExprId("R1", 32), ExprInt(0x2807, 32))], [(ExprId("PC", 32), ExprInt(0x2807, 32)), (ExprId("LP", 32), ExprInt(0x2, 32))])
def test_sw(self): """Test SW execution""" # SW Rn,(Rm) exec_instruction( "SW R1, (R2)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("R2", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x10, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp7.align4(SP) exec_instruction( "SW R1, 4(SP)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("SP", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x14, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp7.align4(TP) exec_instruction( "SW R1, 12(TP)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("TP", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x1c, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp16(Rm) exec_instruction( "SW R10, 0xF800(R2)", [(ExprId("R10", 32), ExprInt(0xABC7, 32)), (ExprId("R2", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0xFFFFF810, 32), 32), ExprInt(0xABC7, 32))]) # SW Rn,(abs24.align4) exec_instruction( "SW R10, (0x1010)", [(ExprId("R10", 32), ExprInt(0xABC7, 32))], [(ExprMem(ExprInt(0x1010, 32), 32), ExprInt(0xABC7, 32))])
def test_ei(self): """Test EI execution""" # EI exec_instruction("EI", [(ExprId("PSW", 32), ExprInt(0, 32))], [(ExprId("PSW", 32), ExprInt(1, 32))])
def test_and(self): """Test AND execution""" # AND Rn, Rm exec_instruction("AND R1, R2", [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))], [(ExprId("R1", 32), ExprInt(0, 32))])
def test_sbvck3(self): """Test SBVCK3 execution""" # SBVCK3 R0,Rn,Rm exec_instruction( "SBVCK3 R0, R1, R2", [(ExprId("R1", 32), ExprInt(2, 32)), (ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R0", 32), ExprCond( ExprOp( ">", ExprInt(3, 32), ExprCond(ExprOp(">", ExprInt(0x2, 32), ExprInt(0x1, 32)), ExprInt(0x2, 32), ExprInt(0x1, 32))), ExprInt(1, 32), ExprInt(0, 32)))]) exec_instruction( "SBVCK3 R0, R1, R2", [(ExprId("R1", 32), ExprInt(0, 32)), (ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R0", 32), ExprCond( ExprOp( ">", ExprInt(1, 32), ExprCond(ExprOp(">", ExprInt(0, 32), ExprInt(1, 32)), ExprInt(0, 32), ExprInt(1, 32))), ExprInt( 1, 32), ExprInt(0, 32)))])
def test_sw(self): """Test SW execution""" # SW Rn,(Rm) exec_instruction("SW R1, (R2)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("R2", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x10, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp7.align4(SP) exec_instruction("SW R1, 4(SP)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("SP", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x14, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp7.align4(TP) exec_instruction("SW R1, 12(TP)", [(ExprId("R1", 32), ExprInt(0x28071010, 32)), (ExprId("TP", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0x1c, 32), 32), ExprInt(0x28071010, 32))]) # SW Rn,disp16(Rm) exec_instruction("SW R10, 0xF800(R2)", [(ExprId("R10", 32), ExprInt(0xABC7, 32)), (ExprId("R2", 32), ExprInt(0x10, 32))], [(ExprMem(ExprInt(0xFFFFF810, 32), 32), ExprInt(0xABC7, 32))]) # SW Rn,(abs24.align4) exec_instruction("SW R10, (0x1010)", [(ExprId("R10", 32), ExprInt(0xABC7, 32))], [(ExprMem(ExprInt(0x1010, 32), 32), ExprInt(0xABC7, 32))])
def test_ret(self): """Test RET execution""" # RET exec_instruction("RET", [(ExprId("LP", 32), ExprInt(0x28, 32))], [(ExprId("PC", 32), ExprInt(0x28, 32))])
def test_reti(self): """Test RETI execution""" # RETI exec_instruction( "RETI", [ (ExprId("PSW", 32), ExprInt(0xF0000201, 32)), # PSW_NMI = 1 (ExprId("NPC", 32), ExprInt(0x43, 32)) ], [(ExprId("PSW", 32), ExprInt(0xF0000001, 32)), (ExprId("PC", 32), ExprInt(0x42, 32))]) exec_instruction( "RETI", [ (ExprId("PSW", 32), ExprInt(0b1010, 32)), # PSW_UMP = 1 & PSW_IEP = 1 (ExprId("EPC", 32), ExprInt(0x29, 32)) ], [ (ExprId("PSW", 32), ExprInt(0b1111, 32)), # PSW_UMC = 1 & PSW_IEC = 1 (ExprId("PC", 32), ExprInt(0x28, 32)) ])
def test_sub(self): """Test SUB execution""" # SUB Rn,Rm exec_instruction("SUB R1, R2", [(ExprId("R1", 32), ExprInt(0x28, 32)), (ExprId("R2", 32), ExprInt(0x7, 32))], [(ExprId("R1", 32), ExprInt(0x21, 32))])
def test_lw(self): """Test SW execution""" # LW Rn,(Rm) exec_instruction("LW R1, (R2)", [(ExprId("R2", 32), ExprInt(0x10, 32)), (ExprMem(ExprInt(0x10, 32), 32), ExprInt(0xABCD, 32))], [(ExprId("R1", 32), ExprInt(0xABCD, 32))]) # LW Rn,disp7.align4(SP) exec_instruction("LW R1, 0x18(SP)", [(ExprId("SP", 32), ExprInt(0x10, 32)), (ExprMem(ExprInt(0x28, 32), 32), ExprInt(0x01234567, 32))], [(ExprId("R1", 32), ExprInt(0x01234567, 32))]) # LW Rn[0-7],disp7.align4(TP) exec_instruction("LW R1, 0x18(TP)", [(ExprId("TP", 32), ExprInt(0x10, 32)), (ExprMem(ExprInt(0x28, 32), 32), ExprInt(0x1010, 32))], [(ExprId("R1", 32), ExprInt(0x1010, 32))]) # LW Rn,disp16(Rm) exec_instruction("LW R9, 0xF000(R2)", [(ExprId("R2", 32), ExprInt(0x42, 32)), (ExprMem(ExprInt(0xFFFFF040, 32), 32), ExprInt(0x10, 32))], [(ExprId("R9", 32), ExprInt(0x10, 32))]) # LW Rn,(abs24.align4) exec_instruction("LW R10, (0x1010)", [(ExprMem(ExprInt(0x1010, 32), 32), ExprInt(0xABC7, 32))], [(ExprId("R10", 32), ExprInt(0xABC7, 32))])
def test_sbvck3(self): """Test SBVCK3 execution""" # SBVCK3 R0,Rn,Rm exec_instruction("SBVCK3 R0, R1, R2", [(ExprId("R1", 32), ExprInt(2, 32)), (ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R0", 32), ExprCond(ExprOp(">", ExprInt(3, 32), ExprCond(ExprOp(">", ExprInt(0x2, 32), ExprInt(0x1, 32)), ExprInt(0x2, 32), ExprInt(0x1, 32))), ExprInt(1, 32), ExprInt(0, 32)))]) exec_instruction("SBVCK3 R0, R1, R2", [(ExprId("R1", 32), ExprInt(0, 32)), (ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R0", 32), ExprCond(ExprOp(">", ExprInt(1, 32), ExprCond(ExprOp(">", ExprInt(0, 32), ExprInt(1, 32)), ExprInt(0, 32), ExprInt(1, 32))), ExprInt(1, 32), ExprInt(0, 32)))])
def test_btstm(self): """Test BTSTM execution""" # BTSTM R0,(Rm),imm3 exec_instruction("BTSTM R0, (R1), 1", [(ExprId("R1", 32), ExprInt(0x28, 32)), (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x2, 8))], [(ExprId("R0", 32), ExprInt(0x2, 32))])
def test_bnotm(self): """Test BNOTM execution""" # BNOTM (Rm),imm3 exec_instruction("BNOTM (R1), 1", [(ExprId("R1", 32), ExprInt(0x28, 32)), (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x1, 8))], [(ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x3, 8))])
def test_sl2ad3(self): """Test SL2AD3 execution""" # SL2AD3 R0,Rn,Rm exec_instruction("SL2AD3 R0, R1, R2", [(ExprId("R1", 32), ExprInt(0x2, 32)), (ExprId("R2", 32), ExprInt(0x20, 32))], [(ExprId("R0", 32), ExprInt(0x28, 32))])
def test_bsetm(self): """Test BSETM execution""" # BSETM (Rm),imm3 exec_instruction("BSETM (R1), 1", [(ExprId("R1", 32), ExprInt(0x28, 32)), (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x1, 8))], [(ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x3, 8))])
def test_tas(self): """Test TAS execution""" # TAS Rn,(Rm) exec_instruction("TAS R0, (R1)", [(ExprId("R1", 32), ExprInt(0x28, 32)), (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x2, 8))], [(ExprId("R0", 32), ExprInt(0x2, 32)), (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x1, 8))])
def test_neg(self): """Test NEG execution""" # NEG Rn,Rm exec_instruction("NEG R1, R2", [(ExprId("R2", 32), ExprInt(1, 32))], [(ExprId("R1", 32), ExprInt(0xFFFFFFFF, 32))]) exec_instruction("NEG R1, R2", [(ExprId("R2", 32), ExprInt(0x42, 32))], [(ExprId("R1", 32), ExprInt(0xFFFFFFBE, 32))])
def test_extb(self): """Test EXTB execution""" # EXTB Rn exec_instruction("EXTB R1", [(ExprId("R1", 32), ExprInt(0xFE, 32))], [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))]) exec_instruction("EXTB R2", [(ExprId("R2", 32), ExprInt(0x80, 32))], [(ExprId("R2", 32), ExprInt(0xFFFFFF80, 32))])
def test_lwcpi(self): """Test LWCPI execution""" # LWCPI CRn[0-15],(Rm+) exec_instruction("LWCPI C1, (R2+)", [(ExprId("R2", 32), ExprInt(0x11, 32)), (ExprMem(ExprInt(0x10, 32), 32), ExprInt(0xABCD, 32))], [(ExprId("C1", 32), ExprInt(0xABCD, 32)), (ExprId("R2", 32), ExprInt(0x15, 32))])
def test_smcpi(self): """Test SMCPI execution""" # SMCPI CRn[0-15],(Rm+) exec_instruction("SMCPI C1, (R2+)", [(ExprId("C1", 32), ExprInt(0x28071010, 32)), (ExprId("R2", 32), ExprInt(0x17, 32))], [(ExprMem(ExprInt(0x10, 32), 32), ExprInt(0x28071010, 32)), (ExprId("R2", 32), ExprInt(0x1F, 32))])
def test_exth(self): """Test EXTH execution""" # EXTH Rn exec_instruction("EXTH R1", [(ExprId("R1", 32), ExprInt(0xFFFE, 32))], [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))]) exec_instruction("EXTH R2", [(ExprId("R2", 32), ExprInt(0x8000, 32))], [(ExprId("R2", 32), ExprInt(0xFFFF8000, 32))])
def test_movh(self): """Test MOVH execution""" # MOVH Rn,imm16 exec_instruction("MOVH R1, 1", [], [(ExprId("R1", 32), ExprInt(0x10000, 32))]) exec_instruction("MOVH R1, 0xFFFF", [], [(ExprId("R1", 32), ExprInt(0xFFFF0000, 32))])
def test_mulru(self): """Test MULRU execution""" # MULRU Rn,Rm exec_instruction("MULRU R0, R1", [(ExprId("R0", 32), ExprInt(0x2, 32)), (ExprId("R1", 32), ExprInt(0xFFFFFFFF, 32))], [(ExprId("HI", 32), ExprInt(0x1, 32)), (ExprId("LO", 32), ExprInt(0xFFFFFFFE, 32)), (ExprId("R0", 32), ExprInt(0xFFFFFFFE, 32))])
def test_repeat(self): """Test REPEAT execution""" # REPEAT Rn, disp17.align2 exec_instruction("REPEAT R0, 0x42", [(ExprId("PC", 32), ExprInt(2, 32)), (ExprId("R0", 32), ExprInt(0x28, 32))], [(ExprId("RPB", 32), ExprInt(6, 32)), (ExprId("RPE", 32), ExprInt(0x44, 32)), (ExprId("RPC", 32), ExprInt(0x28, 32))])
def test_bgei(self): """Test BGEI execution""" # BGEI Rn,imm4,disp17.align2 exec_instruction( "BGEI R1, 0x5, 0x10000", [(ExprId("R1", 32), ExprInt(0x10, 32))], [(ExprId("PC", 32), ExprCond(ExprOp(">=", ExprInt(0x10, 32), ExprInt(0x5, 32)), ExprInt(0xFFFF0010, 32), ExprInt(0x14, 32)))], offset=0x10)
def test_mulr(self): """Test MULR execution""" # MULR Rn,Rm exec_instruction("MULR R0, R1", [(ExprId("R0", 32), ExprInt(0x80, 32)), (ExprId("R1", 32), ExprInt(0xFFFFFFFF, 32))], [(ExprId("HI", 32), ExprInt(0xFFFFFFFF, 32)), (ExprId("LO", 32), ExprInt(0xFFFFFF80, 32)), (ExprId("R0", 32), ExprInt(0xFFFFFF80, 32))])
def test_sll3(self): """Test SLL3 execution""" # SLL3 R0,Rn,imm5 exec_instruction("SLL3 R0, R1, 2", [(ExprId("R1", 32), ExprInt(4, 32))], [(ExprId("R0", 32), ExprInt(16, 32))]) exec_instruction("SLL3 R0, R1, 2", [(ExprId("R1", 32), ExprInt(0xC0000000, 32))], [(ExprId("R0", 32), ExprInt(0, 32))])
def test_extub(self): """Test EXTUB execution""" # EXTUB Rn exec_instruction("EXTUB R1", [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))], [(ExprId("R1", 32), ExprInt(0xFE, 32))]) exec_instruction("EXTUB R2", [(ExprId("R2", 32), ExprInt(0xFFFFFF80, 32))], [(ExprId("R2", 32), ExprInt(0x80, 32))])
def test_extuh(self): """Test EXTUH execution""" # EXTUH Rn exec_instruction("EXTUH R1", [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))], [(ExprId("R1", 32), ExprInt(0xFFFE, 32))]) exec_instruction("EXTUH R2", [(ExprId("R2", 32), ExprInt(0xFFFF8000, 32))], [(ExprId("R2", 32), ExprInt(0x8000, 32))])