small step to making the assmebly process repeatable (is destructive at the moment)

This commit is contained in:
Torsten Ruger 2014-06-05 10:28:53 +03:00
parent 7cc4c6344c
commit 41a02a7190
3 changed files with 8 additions and 4 deletions

View File

@ -92,6 +92,7 @@ module Arm
#slighly wrong place for this code, but since the module gets included in instructions anyway . . . #slighly wrong place for this code, but since the module gets included in instructions anyway . . .
# implement the barrel shifter on the operand (which is set up before as an integer) # implement the barrel shifter on the operand (which is set up before as an integer)
def shift_handling def shift_handling
op = 0
#codes that one can shift, first two probably most common. #codes that one can shift, first two probably most common.
# l (in lsr) means logical, ie unsigned, a (in asr) is arithmetic, ie signed # l (in lsr) means logical, ie unsigned, a (in asr) is arithmetic, ie signed
{'lsl' => 0b000, 'lsr' => 0b010, 'asr' => 0b100, 'ror' => 0b110, 'rrx' => 0b110}.each do |short, bin| {'lsl' => 0b000, 'lsr' => 0b010, 'asr' => 0b100, 'ror' => 0b110, 'rrx' => 0b110}.each do |short, bin|
@ -104,11 +105,12 @@ module Arm
shift = shif.register << 1 shift = shif.register << 1
end end
raise "0 < shift <= 32 #{shif} #{inspect}" if (shif >= 32) or( shif < 0) raise "0 < shift <= 32 #{shif} #{inspect}" if (shif >= 32) or( shif < 0)
@operand |= shift(bin , 4 ) op |= shift(bin , 4 )
@operand |= shift(shif , 4+3) op |= shift(shif , 4+3)
break break
end end
end end
return op
end end
end end
end end

View File

@ -49,13 +49,14 @@ module Arm
else else
raise "invalid operand argument #{right.inspect} , #{inspect}" raise "invalid operand argument #{right.inspect} , #{inspect}"
end end
shift_handling
end end
def assemble(io) def assemble(io)
build build
op = shift_handling
instuction_class = 0b00 # OPC_DATA_PROCESSING instuction_class = 0b00 # OPC_DATA_PROCESSING
val = shift(@operand , 0) val = shift(@operand , 0)
val |= shift(op , 0) # any barral action, is already shifted
val |= shift(reg_code(@result) , 12) val |= shift(reg_code(@result) , 12)
val |= shift(reg_code(@left) , 12+4) val |= shift(reg_code(@left) , 12+4)
val |= shift(@attributes[:update_status] , 12+4+4)#20 val |= shift(@attributes[:update_status] , 12+4+4)#20

View File

@ -52,13 +52,14 @@ module Arm
else else
raise "invalid operand argument #{right.inspect} , #{inspect}" raise "invalid operand argument #{right.inspect} , #{inspect}"
end end
shift_handling
end end
def assemble(io) def assemble(io)
build build
op = shift_handling
instuction_class = 0b00 # OPC_DATA_PROCESSING instuction_class = 0b00 # OPC_DATA_PROCESSING
val = shift(@operand , 0) val = shift(@operand , 0)
val |= shift(op , 0) # any barral action, is already shifted
val |= shift(reg_code(@to) , 12) val |= shift(reg_code(@to) , 12)
val |= shift(reg_code(@rn) , 12+4) val |= shift(reg_code(@rn) , 12+4)
val |= shift(@attributes[:update_status] , 12+4+4)#20 val |= shift(@attributes[:update_status] , 12+4+4)#20