remove NotSame from risc
instead use a - b and then isZero
This commit is contained in:
parent
793fa313a5
commit
6a538624c5
@ -6,6 +6,8 @@ module Mom
|
||||
# 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
|
||||
|
||||
@ -14,12 +16,13 @@ module Mom
|
||||
@left , @right = left , right
|
||||
end
|
||||
|
||||
# basically move both left and right values into register and issue a
|
||||
# risc comparison
|
||||
# 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::NotSame.new(self, l_val.register, r_val.register, false_jump.to_risc(compiler))
|
||||
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
|
||||
|
@ -75,14 +75,6 @@ module Risc
|
||||
end
|
||||
end
|
||||
|
||||
# branch if two registers contain different values
|
||||
class NotSame < Branch
|
||||
attr_reader :left , :right
|
||||
def initialize(source , left , right , label)
|
||||
super(source , label)
|
||||
end
|
||||
end
|
||||
|
||||
class Unconditional < Branch
|
||||
|
||||
end
|
||||
@ -90,7 +82,7 @@ module Risc
|
||||
class IsZero < Branch
|
||||
end
|
||||
|
||||
class IsNotzero < Branch
|
||||
class IsNotZero < Branch
|
||||
end
|
||||
|
||||
class IsMinus < Branch
|
||||
|
Loading…
Reference in New Issue
Block a user