rename risc_value to register_value

almost to register, but it still carries that value
This commit is contained in:
Torsten Ruger
2018-06-29 11:39:07 +03:00
parent 606c7bf906
commit d50893bb0f
21 changed files with 67 additions and 67 deletions

View File

@ -18,19 +18,19 @@ module Arm
rn , operand , immediate= @rn , @operand , 1
arg = @right
operand = Risc::RiscValue.new( arg , :Integer) if( arg.is_a? Symbol )
operand = Risc::RegisterValue.new( arg , :Integer) if( arg.is_a? Symbol )
case operand
when Numeric
operand = arg
raise "numeric literal operand to large #{arg.inspect}" unless (arg.fits_u8?)
when Symbol , ::Risc::RiscValue
when Symbol , ::Risc::RegisterValue
immediate = 0
when Arm::Shift
handle_shift
else
raise "invalid operand argument #{arg.inspect} , #{inspect}"
end
val = (operand.is_a?(Symbol) or operand.is_a?(::Risc::RiscValue)) ? reg_code(operand) : operand
val = (operand.is_a?(Symbol) or operand.is_a?(::Risc::RegisterValue)) ? reg_code(operand) : operand
val = 0 if val == nil
val = shift(val , 0)
raise inspect unless reg_code(@rd)

View File

@ -24,7 +24,7 @@ module Arm
if (right.is_a?(Numeric))
operand = handle_numeric(right)
elsif (right.is_a?(Symbol) or right.is_a?(::Risc::RiscValue))
elsif (right.is_a?(Symbol) or right.is_a?(::Risc::RegisterValue))
operand = reg_code(right) #integer means the register the integer is in (otherwise constant)
immediate = 0 # ie not immediate is register
else
@ -89,7 +89,7 @@ module Arm
# this also loads constants, which are issued as pc relative adds
def determine_operands
if( @left.is_a?(Parfait::Object) or @left.is_a?(Risc::Label) or
(@left.is_a?(Symbol) and !Risc::RiscValue.look_like_reg(@left)))
(@left.is_a?(Symbol) and !Risc::RegisterValue.look_like_reg(@left)))
left = @left
left = left.address if left.is_a?(Risc::Label)
# do pc relative addressing with the difference to the instuction

View File

@ -24,8 +24,8 @@ module Arm
#TODO better test, this operand integer (register) does not work.
def assemble(io)
arg = @left
arg = arg.symbol if( arg.is_a? ::Risc::RiscValue )
is_reg = arg.is_a?(::Risc::RiscValue)
arg = arg.symbol if( arg.is_a? ::Risc::RegisterValue )
is_reg = arg.is_a?(::Risc::RegisterValue)
is_reg = (arg.to_s[0] == "r") if( arg.is_a?(Symbol) and not is_reg)
raise "invalid operand argument #{arg.inspect} #{inspect}" unless (is_reg )
@ -34,7 +34,7 @@ module Arm
#not sure about these 2 constants. They produce the correct output for str r0 , r1
# but i can't help thinking that that is because they are not used in that instruction and
# so it doesn't matter. Will see
if (operand.is_a?(Symbol) or operand.is_a?(::Risc::RiscValue))
if (operand.is_a?(Symbol) or operand.is_a?(::Risc::RegisterValue))
val = reg_code(operand)
i = 1 # not quite sure about this, but it gives the output of as. read read read.
else
@ -66,7 +66,7 @@ module Arm
def get_operand
return @operand unless @right
operand = @right
operand = operand.symbol if operand.is_a? ::Risc::RiscValue
operand = operand.symbol if operand.is_a? ::Risc::RegisterValue
unless( operand.is_a? Symbol)
# TODO test/check/understand: has no effect in current tests
# add_offset = (operand < 0) ? 0 : 1

View File

@ -4,8 +4,8 @@ module Arm
def initialize( to , from , options = {})
super(nil)
@attributes = options
if( from.is_a?(Symbol) and Risc::RiscValue.look_like_reg(from) )
from = Risc::RiscValue.new(from , :Integer)
if( from.is_a?(Symbol) and Risc::RegisterValue.look_like_reg(from) )
from = Risc::RegisterValue.new(from , :Integer)
end
@from = from
@to = to
@ -28,7 +28,7 @@ module Arm
case right
when Numeric
operand = numeric_operand(right)
when Risc::RiscValue
when Risc::RegisterValue
operand = reg_code(right)
immediate = 0 # ie not immediate is register
else