2014-08-22 16:40:09 +02:00
|
|
|
module Register
|
2014-09-14 17:15:33 +02:00
|
|
|
class UnusedAndAbandonedInteger < Word
|
2014-06-25 01:47:59 +02:00
|
|
|
# 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 )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :le
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
def greater_or_equal block , right
|
|
|
|
block.cmp( self , right )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :ge
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
def greater_than block , right
|
|
|
|
block.cmp( self , right )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :gt
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
def less_than block , right
|
|
|
|
block.cmp( self , right )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :lt
|
2014-06-25 01:47:59 +02:00
|
|
|
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 )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :eq
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def is_true? function
|
|
|
|
function.cmp( self , 0 )
|
2014-08-22 17:00:23 +02:00
|
|
|
Register::BranchCondition.new :ne
|
2014-06-25 01:47:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def move block , right
|
|
|
|
block.mov( self , right )
|
|
|
|
self
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|