move fits_u8 to integer constant (from numberic)
This commit is contained in:
parent
95c7e44342
commit
e7f7f9c319
@ -29,7 +29,7 @@ module Arm
|
|||||||
arg = Register::RegisterReference.new( arg )
|
arg = Register::RegisterReference.new( arg )
|
||||||
end
|
end
|
||||||
if (arg.is_a?(Virtual::IntegerConstant))
|
if (arg.is_a?(Virtual::IntegerConstant))
|
||||||
if (arg.integer.fits_u8?)
|
if (arg.fits_u8?)
|
||||||
# no shifting needed
|
# no shifting needed
|
||||||
operand = arg.integer
|
operand = arg.integer
|
||||||
immediate = 1
|
immediate = 1
|
||||||
|
@ -78,7 +78,7 @@ module Arm
|
|||||||
else
|
else
|
||||||
u8_imm = parts[1].to_i(2)
|
u8_imm = parts[1].to_i(2)
|
||||||
end
|
end
|
||||||
if (u8_imm.fits_u8?)
|
if (Virtual::IntegerConstant.new(u8_imm).fits_u8?)
|
||||||
# can do!
|
# can do!
|
||||||
rot_imm = (pre_zeros+imm_len) / 2
|
rot_imm = (pre_zeros+imm_len) / 2
|
||||||
if (rot_imm > 15)
|
if (rot_imm > 15)
|
||||||
|
@ -31,7 +31,7 @@ module Arm
|
|||||||
right = Virtual::IntegerConstant.new( right )
|
right = Virtual::IntegerConstant.new( right )
|
||||||
end
|
end
|
||||||
if (right.is_a?(Virtual::IntegerConstant))
|
if (right.is_a?(Virtual::IntegerConstant))
|
||||||
if true #TODO (right.integer.fits_u8?)
|
if true #TODO (right.fits_u8?)
|
||||||
# no shifting needed
|
# no shifting needed
|
||||||
operand = right.integer
|
operand = right.integer
|
||||||
immediate = 1
|
immediate = 1
|
||||||
|
@ -35,7 +35,7 @@ module Arm
|
|||||||
right = Virtual::IntegerConstant.new( r_pos - self.position - 8 )
|
right = Virtual::IntegerConstant.new( r_pos - self.position - 8 )
|
||||||
end
|
end
|
||||||
if (right.is_a?(Virtual::IntegerConstant))
|
if (right.is_a?(Virtual::IntegerConstant))
|
||||||
if (right.integer.fits_u8?)
|
if (right.fits_u8?)
|
||||||
return true
|
return true
|
||||||
elsif (calculate_u8_with_rr(right))
|
elsif (calculate_u8_with_rr(right))
|
||||||
return true
|
return true
|
||||||
@ -63,7 +63,7 @@ module Arm
|
|||||||
rn = :pc
|
rn = :pc
|
||||||
end
|
end
|
||||||
if (right.is_a?(Virtual::IntegerConstant))
|
if (right.is_a?(Virtual::IntegerConstant))
|
||||||
if (right.integer.fits_u8?)
|
if (right.fits_u8?)
|
||||||
# no shifting needed
|
# no shifting needed
|
||||||
operand = right.integer
|
operand = right.integer
|
||||||
immediate = 1
|
immediate = 1
|
||||||
@ -75,7 +75,7 @@ module Arm
|
|||||||
operand = right.integer / 256
|
operand = right.integer / 256
|
||||||
immediate = 1
|
immediate = 1
|
||||||
|
|
||||||
# raise "cannot fit numeric literal argument in operand #{right.inspect}"
|
raise "cannot fit numeric literal argument in operand #{right.inspect}"
|
||||||
end
|
end
|
||||||
elsif (right.is_a?(Symbol) or right.is_a?(Virtual::Integer))
|
elsif (right.is_a?(Symbol) or right.is_a?(Virtual::Integer))
|
||||||
operand = reg_code(right) #integer means the register the integer is in (otherwise constant)
|
operand = reg_code(right) #integer means the register the integer is in (otherwise constant)
|
||||||
|
@ -1,9 +1,3 @@
|
|||||||
class Numeric
|
|
||||||
def fits_u8?
|
|
||||||
self >= 0 and self <= 255
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module StreamReader
|
module StreamReader
|
||||||
def read_binary(size, count, type)
|
def read_binary(size, count, type)
|
||||||
d = __sr_read(size*count)
|
d = __sr_read(size*count)
|
||||||
|
@ -28,6 +28,9 @@ module Virtual
|
|||||||
def type
|
def type
|
||||||
Virtual::Integer
|
Virtual::Integer
|
||||||
end
|
end
|
||||||
|
def fits_u8?
|
||||||
|
integer >= 0 and integer <= 255
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The name really says it all.
|
# The name really says it all.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user