move a function out of the builder to tools for clarity
This commit is contained in:
parent
ced82628d4
commit
b2f45d9f9c
@ -55,4 +55,27 @@ module Asm
|
|||||||
ref
|
ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def calculate_u8_with_rr(arg)
|
||||||
|
parts = arg.value.to_s(2).rjust(32,'0').scan(/^(0*)(.+?)0*$/).flatten
|
||||||
|
pre_zeros = parts[0].length
|
||||||
|
imm_len = parts[1].length
|
||||||
|
if ((pre_zeros+imm_len) % 2 == 1)
|
||||||
|
u8_imm = (parts[1]+'0').to_i(2)
|
||||||
|
imm_len += 1
|
||||||
|
else
|
||||||
|
u8_imm = parts[1].to_i(2)
|
||||||
|
end
|
||||||
|
if (u8_imm.fits_u8?)
|
||||||
|
# can do!
|
||||||
|
rot_imm = (pre_zeros+imm_len) / 2
|
||||||
|
if (rot_imm > 15)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return u8_imm | (rot_imm << 8)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
@ -19,28 +19,6 @@ module Asm
|
|||||||
attr_accessor :cond, :inst_class, :i, :opcode, :s,
|
attr_accessor :cond, :inst_class, :i, :opcode, :s,
|
||||||
:rn, :rd, :operand
|
:rn, :rd, :operand
|
||||||
|
|
||||||
def calculate_u8_with_rr(arg)
|
|
||||||
parts = arg.value.to_s(2).rjust(32,'0').scan(/^(0*)(.+?)0*$/).flatten
|
|
||||||
pre_zeros = parts[0].length
|
|
||||||
imm_len = parts[1].length
|
|
||||||
if ((pre_zeros+imm_len) % 2 == 1)
|
|
||||||
u8_imm = (parts[1]+'0').to_i(2)
|
|
||||||
imm_len += 1
|
|
||||||
else
|
|
||||||
u8_imm = parts[1].to_i(2)
|
|
||||||
end
|
|
||||||
if (u8_imm.fits_u8?)
|
|
||||||
# can do!
|
|
||||||
rot_imm = (pre_zeros+imm_len) / 2
|
|
||||||
if (rot_imm > 15)
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
return u8_imm | (rot_imm << 8)
|
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build representation for source value
|
# Build representation for source value
|
||||||
def build_operand(arg , position = 0)
|
def build_operand(arg , position = 0)
|
||||||
#position only needed for calculating relative addresses to data objects
|
#position only needed for calculating relative addresses to data objects
|
||||||
|
Loading…
Reference in New Issue
Block a user