51 lines
1.2 KiB
Ruby
51 lines
1.2 KiB
Ruby
module Register
|
|
class UnusedAndAbandonedInteger < Word
|
|
# needs to be here as Word's constructor is private (to make it abstract)
|
|
def initialize reg
|
|
super
|
|
end
|
|
|
|
def less_or_equal block , right
|
|
block.cmp( self , right )
|
|
Register::BranchCondition.new :le
|
|
end
|
|
def greater_or_equal block , right
|
|
block.cmp( self , right )
|
|
Register::BranchCondition.new :ge
|
|
end
|
|
def greater_than block , right
|
|
block.cmp( self , right )
|
|
Register::BranchCondition.new :gt
|
|
end
|
|
def less_than block , right
|
|
block.cmp( self , right )
|
|
Register::BranchCondition.new :lt
|
|
end
|
|
def plus block , first , right
|
|
block.add( self , left , right )
|
|
self
|
|
end
|
|
def minus block , left , right
|
|
block.sub( self , left , right )
|
|
self
|
|
end
|
|
def left_shift block , left , right
|
|
block.mov( self , left , shift_lsr: right )
|
|
self
|
|
end
|
|
def equals block , right
|
|
block.cmp( self , right )
|
|
Register::BranchCondition.new :eq
|
|
end
|
|
|
|
def is_true? function
|
|
function.cmp( self , 0 )
|
|
Register::BranchCondition.new :ne
|
|
end
|
|
|
|
def move block , right
|
|
block.mov( self , right )
|
|
self
|
|
end
|
|
end
|
|
end |