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
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
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
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
def copy_register(self, other): return self.code.add(x86.addi(self, other, 0))