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
|
# The values that are compared are defined as SlotDefinitions, ie can be anything
|
||||||
# available to the machine through frame message or self
|
# 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
|
class NotSameCheck < Check
|
||||||
attr_reader :left , :right
|
attr_reader :left , :right
|
||||||
|
|
||||||
@ -14,12 +16,13 @@ module Mom
|
|||||||
@left , @right = left , right
|
@left , @right = left , right
|
||||||
end
|
end
|
||||||
|
|
||||||
# basically move both left and right values into register and issue a
|
# basically move both left and right values into register
|
||||||
# risc comparison
|
# subtract them and see if IsZero comparison
|
||||||
def to_risc(compiler)
|
def to_risc(compiler)
|
||||||
l_val = left.to_register(compiler, self)
|
l_val = left.to_register(compiler, self)
|
||||||
r_val = right.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
|
l_val << r_val << check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,14 +75,6 @@ module Risc
|
|||||||
end
|
end
|
||||||
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
|
class Unconditional < Branch
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -90,7 +82,7 @@ module Risc
|
|||||||
class IsZero < Branch
|
class IsZero < Branch
|
||||||
end
|
end
|
||||||
|
|
||||||
class IsNotzero < Branch
|
class IsNotZero < Branch
|
||||||
end
|
end
|
||||||
|
|
||||||
class IsMinus < Branch
|
class IsMinus < Branch
|
||||||
|
Loading…
Reference in New Issue
Block a user