Permalink
Browse files

register? is more robust, rm? works with sizes properly, e.g. [:byte,…

… <addr/var>]
  • Loading branch information...
1 parent f9acae7 commit b3dad0b947576af070ca3a930b3a24b83ede25aa @samsonjs committed Jan 21, 2010
Showing with 11 additions and 4 deletions.
  1. +11 −4 asm/binary.rb
View
@@ -447,7 +447,8 @@ def mk_sib(scale, index, base)
def register?(op, size=DefaultOperandSize)
- op.is_a?(RegisterProxy) && op.size == size || op.size == SizeMap[size]
+ op.is_a?(RegisterProxy) && op.size == size ||
+ op.respond_to?(:size) && op.size == SizeMap[size]
end
def immediate?(op, size=DefaultOperandSize)
@@ -466,10 +467,16 @@ def immediate?(op, size=DefaultOperandSize)
#
# XXX This method is pretty ugly.
def rm?(op, size=DefaultOperandSize)
+ # register
register?(op, size) ||
- (op.is_a?(Array) &&
- (op.size == 1 && [Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[0].class}) ||
- (op.size == 2 && rm?(op[1])))
+
+ # [register/memory]
+ (op.is_a?(Array) && op.size == 1 &&
+ [Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[0].class}) ||
+
+ # [<size>, memory]
+ (op.is_a?(Array) && op.size == 2 && op[0] == size &&
+ [Numeric, RegisterProxy, VariableProxy].any?{|c| c == op[1].class})
end
def offset?(addr, size=DefaultOperandSize)

0 comments on commit b3dad0b

Please sign in to comment.