From b3dad0b947576af070ca3a930b3a24b83ede25aa Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 20 Jan 2010 23:17:34 -0800 Subject: [PATCH] register? is more robust, rm? works with sizes properly, e.g. [:byte, ] --- asm/binary.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/asm/binary.rb b/asm/binary.rb index 391fd92..81dbd53 100644 --- a/asm/binary.rb +++ b/asm/binary.rb @@ -447,7 +447,8 @@ module Assembler 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 @@ module Assembler # # 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}) || + + # [, 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)