コード例 #1
0
ファイル: x86_64_types.py プロジェクト: KapilRijhwani/corepy
 def _set_literal_value(self, value):
   # Put the lower 16 bits into r-temp
   self.code.add(x86.addi(self.reg, 0, value))
 
   # Addis r-temp with the upper 16 bits (shifted add immediate) and
   # put the result in r-target
   if (value & 0x7FFF) != value:
     self.code.add(x86.addis(self.reg, self.reg, ((value + 32768) >> 16)))
     
   return
コード例 #2
0
    def _set_literal_value(self, value):
        # Put the lower 16 bits into r-temp
        self.code.add(x86.addi(self.reg, 0, value))

        # Addis r-temp with the upper 16 bits (shifted add immediate) and
        # put the result in r-target
        if (value & 0x7FFF) != value:
            self.code.add(
                x86.addis(self.reg, self.reg, ((value + 32768) >> 16)))

        return
コード例 #3
0
def SimpleTest():
    """
  Just make sure things are working...
  """
    from corepy.arch.x86.platform import Processor, InstructionStream

    code = InstructionStream()
    proc = Processor()

    # Without active code
    a = SignedWord(11, code)
    b = SignedWord(31, reg=code.acquire_register())
    c = SignedWord(reg=code.gp_return)

    byte_mask = Bits(0xFF, code)
    code.add(x86.addi(code.gp_return, 0, 31))

    # c.v = a + SignedWord.cast(b & byte_mask) + 12
    c.v = a + (byte_mask & b) + 12

    if True:
        r = proc.execute(code)
        assert (r == (42 + 12))

    # With active code
    code.reset()

    x86.set_active_code(code)

    a = SignedWord(11)
    b = SignedWord(31)
    c = SignedWord(reg=code.gp_return)

    byte_mask = Bits(0xFF)

    c.v = a + (b & byte_mask)

    x86.set_active_code(None)
    r = proc.execute(code)
    # code.print_code()
    assert (r == 42)
    return
コード例 #4
0
ファイル: x86_64_types.py プロジェクト: KapilRijhwani/corepy
def SimpleTest():
  """
  Just make sure things are working...
  """
  from corepy.arch.x86.platform import Processor, InstructionStream

  code = InstructionStream()
  proc = Processor()

  # Without active code
  a = SignedWord(11, code)
  b = SignedWord(31, reg = code.acquire_register())
  c = SignedWord(reg = code.gp_return)

  byte_mask = Bits(0xFF, code)
  code.add(x86.addi(code.gp_return, 0, 31))

  # c.v = a + SignedWord.cast(b & byte_mask) + 12
  c.v = a + (byte_mask & b) + 12

  if True:
    r = proc.execute(code)
    assert(r == (42 + 12))
  
  # With active code
  code.reset()

  x86.set_active_code(code)
  
  a = SignedWord(11)
  b = SignedWord(31)
  c = SignedWord(reg = code.gp_return)

  byte_mask = Bits(0xFF)

  c.v = a + (b & byte_mask)

  x86.set_active_code(None)
  r = proc.execute(code)
  # code.print_code()
  assert(r == 42)
  return
コード例 #5
0
 def copy_register(self, other):
     return self.code.add(x86.addi(self, other, 0))
コード例 #6
0
ファイル: x86_64_types.py プロジェクト: KapilRijhwani/corepy
 def copy_register(self, other):
   return self.code.add(x86.addi(self, other, 0))