1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# Toshiba MeP-c4 - Bit manipulation instructions unit tests
# Guillaume Valadon <guillaume@valadon.net>
from ut_helpers_ir import exec_instruction
from miasm.expression.expression import ExprId, ExprInt, ExprMem
class TestBitManipulation(object):
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))])
|