예제 #1
0
파일: arch.py 프로젝트: pombredanne/miasm-1
 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 = ExprInt32(v + 4)
     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 = 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
예제 #5
0
파일: arch.py 프로젝트: pombredanne/miasm-1
 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
     # 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
예제 #7
0
파일: arch.py 프로젝트: pombredanne/miasm-1
 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
예제 #8
0
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 16, 32)
     self.expr = ExprInt32(v)
     return True
예제 #9
0
파일: arch.py 프로젝트: pombredanne/miasm-1
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 16, 32)
     self.expr = ExprInt(v, 32)
     return True
예제 #10
0
파일: arch.py 프로젝트: pmarkowsky/miasm
 def decode(self, v):
     v = v & self.lmask
     v <<= 2
     v = cpu.sign_ext(v, 16 + 2, 32)
     self.expr = ExprInt32(v)
     return True