rubyx/lib/mom/instruction/not_same_check.rb
Torsten Ruger 6a538624c5 remove NotSame from risc
instead use a - b and then  isZero
2018-03-24 17:54:15 +02:00

30 lines
983 B
Ruby

module Mom
# Mom internal check, as the name says to see if two values are not the same
# In other words, we this checks identity, bit-values, pointers
#
# The values that are compared are defined as SlotDefinitions, ie can be anything
# available to the machine through frame message or self
#
# Acording to Mom::Check logic, we jump to the given label is the values are the same
#
class NotSameCheck < Check
attr_reader :left , :right
def initialize(left, right , label)
super(label)
@left , @right = left , right
end
# basically move both left and right values into register
# subtract them and see if IsZero comparison
def to_risc(compiler)
l_val = left.to_register(compiler, self)
r_val = right.to_register(compiler, self)
check = Risc.op( self , :- , l_val.register , r_val.register)
check << Risc::IsZero.new( self, false_jump.to_risc(compiler))
l_val << r_val << check
end
end
end