diff python/ppci/target/arm/instructions.py @ 362:c05ab629976a

Added CPUID for arm
author Windel Bouwman
date Sat, 15 Mar 2014 10:56:34 +0100
parents 42343d189e14
children c49459768aaa
line wrap: on
line diff
--- a/python/ppci/target/arm/instructions.py	Fri Mar 14 16:18:54 2014 +0100
+++ b/python/ppci/target/arm/instructions.py	Sat Mar 15 10:56:34 2014 +0100
@@ -495,3 +495,36 @@
         self.token[16:23] = 0b0011111
         self.token[24:28] = 0b0101
         return self.token.encode()
+
+
+class McrBase(ArmInstruction):
+    """ Mov arm register to coprocessor register """
+    def __init__(self, coproc, opc1, rt, crn, crm, opc2):
+        super().__init__()
+        self.coproc = coproc
+        self.opc1 = opc1
+        self.rt = rt
+        self.crn = crn
+        self.crm = crm
+        self.opc2 = opc2
+
+    def encode(self):
+        self.token[0:4] = self.crm
+        self.token[4] = 1
+        self.token[5:8] = self.opc2
+        self.token[8:12] = self.coproc
+        self.token[12:16] = self.rt.num
+        self.token[16:20] = self.crn
+        self.token[20] = self.b20
+        self.token[21:24] = self.opc1
+        self.token[24:28] = 0b1110
+        self.token.cond = AL
+        return self.token.encode()
+
+
+class Mcr(McrBase):
+    b20 = 0
+
+
+class Mrc(McrBase):
+    b20 = 1