diff options
Diffstat (limited to 'test/arch/mep/ir/test_bitmanipulation.py')
| -rw-r--r-- | test/arch/mep/ir/test_bitmanipulation.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/arch/mep/ir/test_bitmanipulation.py b/test/arch/mep/ir/test_bitmanipulation.py new file mode 100644 index 00000000..06466f9d --- /dev/null +++ b/test/arch/mep/ir/test_bitmanipulation.py @@ -0,0 +1,55 @@ +# Toshiba MeP-c4 - Bit manipulation instructions unit tests +# Guillaume Valadon <guillaume@valadon.net> + +from ut_helpers_ir import exec_instruction + +from miasm2.expression.expression import ExprId, ExprInt, ExprMem + + +class TestBitManipulation: + + 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_bclrm(self): + """Test BCLRM execution""" + + # BCLRM (Rm),imm3 + exec_instruction("BCLRM (R1), 1", + [(ExprId("R1", 32), ExprInt(0x28, 32)), + (ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x3, 8))], + [(ExprMem(ExprInt(0x28, 32), 8), ExprInt(0x1, 8))]) + + 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_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_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))]) |