Exemplo n.º 1
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
Exemplo n.º 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
Exemplo n.º 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))])
Exemplo n.º 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
Exemplo n.º 5
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
Exemplo n.º 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
Exemplo n.º 7
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
Exemplo n.º 8
0
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 16, 32)
     self.expr = ExprInt32(v)
     return True
Exemplo n.º 9
0
 def decode(self, v):
     v = v & self.lmask
     v = cpu.sign_ext(v, 16, 32)
     self.expr = ExprInt(v, 32)
     return True
Exemplo n.º 10
0
 def decode(self, v):
     v = v & self.lmask
     v <<= 2
     v = cpu.sign_ext(v, 16 + 2, 32)
     self.expr = ExprInt32(v)
     return True