示例#1
0
文件: arch.py 项目: cea-sec/miasm
 def decode(self, v):
     v = v & self.lmask
     v <<= 2
     v = cpu.sign_ext(v, 16+2, 32)
     # Add pipeline offset
     self.expr = ExprInt(v + 4, 32)
     return True
示例#2
0
 def decode(self, v):
     v = v & self.lmask
     v <<= 2
     v = cpu.sign_ext(v, 16 + 2, 32)
     # Add pipeline offset
     self.expr = ExprInt(v + 4, 32)
     return True
示例#3
0
    def test_sra(self):
        """Test SRA execution"""

        # SRA Rn, Rm
        exec_instruction("SRA R1, R2",
                         [(ExprId("R1", 32), ExprInt(4, 32)), (ExprId("R2", 32), ExprInt(1, 32))],
                         [(ExprId("R1", 32), ExprInt(2, 32))])

        exec_instruction("SRA R1, R2",
                         [(ExprId("R1", 32), ExprInt(sign_ext(4, 3, 32), 32)), (ExprId("R2", 32), ExprInt(1, 32))],
                         [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))])

        exec_instruction("SRA R1, R2",
                         [(ExprId("R1", 32), ExprInt(0xF0000000, 32)), (ExprId("R2", 32), ExprInt(4, 32))],
                         [(ExprId("R1", 32), ExprInt(0xFF000000, 32))])

        # SRA Rn,imm5
        exec_instruction("SRA R1, 1",
                         [(ExprId("R1", 32), ExprInt(4, 32))],
                         [(ExprId("R1", 32), ExprInt(2, 32))])

        # SRA Rn,imm5
        exec_instruction("SRA R1, 1",
                         [(ExprId("R1", 32), ExprInt(0x80000000, 32))],
                         [(ExprId("R1", 32), ExprInt(0xC0000000, 32))])

        exec_instruction("SRA R1, 1",
                         [(ExprId("R1", 32), ExprInt(1, 32))],
                         [(ExprId("R1", 32), ExprInt(0, 32))])
示例#4
0
 def encode(self):
     if not isinstance(self.expr, ExprInt):
         return False
     v = int(self.expr)
     if v & 0x80000000:
         nv = v & ((1 << 9) - 1)
         assert (v == cpu.sign_ext(nv, 9, 32))
         v = nv
     self.value = v
     return True
示例#5
0
文件: arch.py 项目: cea-sec/miasm
 def encode(self):
     if not isinstance(self.expr, ExprInt):
         return False
     v = self.expr.arg.arg
     if v & 0x80000000:
         nv = v & ((1 << 16) - 1)
         assert( v == cpu.sign_ext(nv, 16, 32))
         v = nv
     self.value = v
     return True
示例#6
0
 def encode(self):
     if not isinstance(self.expr, ExprInt):
         return False
     v = self.expr.arg.arg
     if v & 0x80000000:
         nv = v & ((1 << 16) - 1)
         assert (v == cpu.sign_ext(nv, 16, 32))
         v = nv
     self.value = v
     return True
示例#7
0
 def encode(self):
     if not isinstance(self.expr, ExprInt):
         return False
     # Remove pipeline offset
     v = (int(self.expr) - 4) & 0xFFFFFFFF
     if v & 0x80000000:
         nv = v & ((1 << 16 + 2) - 1)
         assert (v == cpu.sign_ext(nv, 16 + 2, 32))
         v = nv
     self.value = v >> 2
     return True
示例#8
0
文件: arch.py 项目: cea-sec/miasm
 def encode(self):
     if not isinstance(self.expr, ExprInt):
         return False
     # Remove pipeline offset
     v = int(self.expr.arg - 4)
     if v & 0x80000000:
         nv = v & ((1 << 16+2) - 1)
         assert( v == cpu.sign_ext(nv, 16+2, 32))
         v = nv
     self.value = v>>2
     return True
示例#9
0
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 9, 32)
     self.expr = ExprInt(v, 32)
     return True
示例#10
0
文件: arch.py 项目: cea-sec/miasm
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 16, 32)
     self.expr = ExprInt(v, 32)
     return True