Skip to content

Commit cb39148

Browse files
certikMaratyszcza
authored andcommitted
Allow asm printing for CALL(RIPRelativeOffset(3)) (#105)
Previously it printed: CALL <peachpy.x86_64.operand.RIPRelativeOffset object at 0x7f6e1e126430> Now it prints: CALL rip+28
1 parent fca3f81 commit cb39148

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

peachpy/x86_64/operand.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ def __add__(self, extra_offset):
427427
def __sub__(self, extra_offset):
428428
return RIPRelativeOffset(self.offset - extra_offset)
429429

430+
def __str__(self):
431+
return self.format("peachpy")
432+
433+
def format(self, assembly_format):
434+
if assembly_format == "gas":
435+
return "%d(%%rip)" % self.offset
436+
elif assembly_format == "go":
437+
return "%d(IP)" % self.offset
438+
else:
439+
return "rip%+d" % self.offset
440+
430441

431442
def is_al(operand):
432443
from peachpy.x86_64.registers import GeneralPurposeRegister8, al

0 commit comments

Comments
 (0)