about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2017-09-24 19:06:29 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2017-09-24 19:06:29 +0200
commita3fb47b449057c1daa0b6e57c2c3ba4dd7045f37 (patch)
treea00e460c431d09f13ae76084b0622d681083b104
parentf280c6053956f88912c4ff360b21ccea6e45ed43 (diff)
downloadmiasm-a3fb47b449057c1daa0b6e57c2c3ba4dd7045f37.tar.gz
miasm-a3fb47b449057c1daa0b6e57c2c3ba4dd7045f37.zip
Armt: add instr nop/cps/wfi
Diffstat (limited to '')
-rw-r--r--miasm2/arch/arm/arch.py34
-rw-r--r--test/arch/arm/arch.py11
2 files changed, 45 insertions, 0 deletions
diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py
index a8fb2650..c74d10a8 100644
--- a/miasm2/arch/arm/arch.py
+++ b/miasm2/arch/arm/arch.py
@@ -2384,6 +2384,35 @@ class armt_imm5_1(arm_imm):
         self.value = (v >> 1) & 0x1f
         return True
 
+aif_str = ["X", "F", "I", "IF", "A", "AF", "AI", "AIF"]
+aif_expr = [ExprId(x, 32) if x != None else None for x in aif_str]
+
+aif_reg = reg_info(aif_str, aif_expr)
+
+class armt_aif(reg_noarg, m_arg):
+    reg_info = aif_reg
+    parser = reg_info.parser
+
+    def decode(self, v):
+        if v == 0:
+            return False
+        return super(armt_aif, self).decode(v)
+
+    def encode(self):
+        ret = super(armt_aif, self).encode()
+        if not ret:
+            return ret
+        return self.value != 0
+
+    def fromstring(self, s, parser_result=None):
+        start, stop = super(armt_aif, self).fromstring(s, parser_result)
+        if self.expr.name == "X":
+            return None, None
+        return start, stop
+
+aif = bs(l=3, cls=(armt_aif,))
+
+
 imm5_off = bs(l=5, cls=(armt_imm5_1,), fname="imm5_off")
 
 tsign = bs(l=1, fname="sign")
@@ -2407,3 +2436,8 @@ armtop("cbz", [bs('101100'), imm1, bs('1'), imm5_off, rnl], [rnl, imm5_off])
 armtop("cbnz", [bs('101110'), imm1, bs('1'), imm5_off, rnl], [rnl, imm5_off])
 
 armtop("bkpt", [bs('1011'), bs('1110'), imm8])
+
+armtop("nop", [bs8(0xBF),bs8(0x0)])
+armtop("wfi", [bs8(0xBF),bs8(0x30)])
+armtop("cpsid", [bs8(0xB6),bs('0111'), bs('0'), aif], [aif])
+armtop("cpsie", [bs8(0xB6),bs('0110'), bs('0'), aif], [aif])
diff --git a/test/arch/arm/arch.py b/test/arch/arm/arch.py
index cb0e56fe..3ba2dbd4 100644
--- a/test/arch/arm/arch.py
+++ b/test/arch/arm/arch.py
@@ -478,6 +478,17 @@ reg_tests_armt = [
     ("xxxxxxxx    SVC        0x13",
      "13df"),
 
+    ("xxxxxxxx    NOP        ",
+     "00bf"),
+
+    ("xxxxxxxx    CPSID      AIF",
+     "77B6"),
+    ("xxxxxxxx    CPSIE      I",
+     "62B6"),
+
+    ("xxxxxxxx    WFI        ",
+     "30bf"),
+
 ]
 print "#" * 40, 'armthumb', '#' * 40