Skip to content

Commit

Permalink
x86-64: accept Constant objects as memory operands
Browse files Browse the repository at this point in the history
  • Loading branch information
Maratyszcza committed Aug 19, 2015
1 parent f5cb380 commit 5850b9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion peachpy/x86_64/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ def format(self, assembly_format="peachpy", line_separator=os.linesep):
if line_separator is None:
return code
else:
return str(line_separator).join(code)
return str(line_separator).join(filter(bool, code))

def load(self):
return ExecutableFuntion(self)
Expand Down
23 changes: 17 additions & 6 deletions peachpy/x86_64/operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def check_operand(operand):
from peachpy.x86_64.registers import Register
from peachpy.x86_64.pseudo import Label
from peachpy.x86_64.function import LocalVariable
from peachpy import Constant, Argument
from peachpy.literal import Constant
from peachpy import Argument
from peachpy.util import is_int, is_int64
if isinstance(operand, (Register, Constant, MemoryOperand, LocalVariable, Argument, RIPRelativeOffset, Label)):
return operand
Expand Down Expand Up @@ -374,27 +375,37 @@ def is_m8(operand, strict=False):


def is_m16(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 2)
import peachpy.literal
return is_m(operand) and (operand.size is None and not strict or operand.size == 2) or \
isinstance(operand, peachpy.literal.Constant) and operand.size == 2


def is_m32(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 4)
import peachpy.literal
return is_m(operand) and (operand.size is None and not strict or operand.size == 4) or \
isinstance(operand, peachpy.literal.Constant) and operand.size == 4


def is_m64(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 8)
import peachpy.literal
return is_m(operand) and (operand.size is None and not strict or operand.size == 8) or \
isinstance(operand, peachpy.literal.Constant) and operand.size == 8


def is_m80(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 10)


def is_m128(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 16)
import peachpy.literal
return is_m(operand) and (operand.size is None and not strict or operand.size == 16) or \
isinstance(operand, peachpy.literal.Constant) and operand.size == 16


def is_m256(operand, strict=False):
return is_m(operand) and (operand.size is None and not strict or operand.size == 32)
import peachpy.literal
return is_m(operand) and (operand.size is None and not strict or operand.size == 32) or \
isinstance(operand, peachpy.literal.Constant) and operand.size == 32


def is_vm32x(operand, strict=False):
Expand Down

0 comments on commit 5850b9c

Please sign in to comment.