introduce constant class and add block to compile signature(wip, work in progress)

This commit is contained in:
Torsten Ruger
2014-05-13 16:24:19 +03:00
parent dd05b30230
commit d7f31e7f39
15 changed files with 145 additions and 140 deletions

View File

@ -30,7 +30,15 @@ module Arm
end
end
end
def integer_less_or_equal left , right
cmp(:left => left , :right => right )
end
def integer_plus left , right
add(:left => left , :right => right )
end
def word_load value , reg
raise "not a register :#{reg}:" unless reg.class == Symbol
mov( :left => reg , :right => value )

View File

@ -39,11 +39,11 @@ module Arm
# Add a string to the string table. Strings are global and constant. So only one copy of each
# string exists
# Internally StringLiterals are created and stored and during assembly written after the blocks
# Internally StringConstants are created and stored and during assembly written after the blocks
def add_string str
code = @string_table[str]
return code if code
data = Vm::StringLiteral.new(str)
data = Vm::StringConstant.new(str)
@string_table[str] = data
end

View File

@ -22,7 +22,7 @@ module Arm
#(stays in subclases, while build is overriden to provide different arguments)
def do_build(arg)
if arg.is_a?(Vm::StringLiteral)
if arg.is_a?(Vm::StringConstant)
# do pc relative addressing with the difference to the instuction
# 8 is for the funny pipeline adjustment (ie oc pointing to fetch and not execute)
arg = Arm::NumLiteral.new( arg.position - self.position - 8 )
@ -31,7 +31,7 @@ module Arm
if( arg.is_a? Fixnum ) #HACK to not have to change the code just now
arg = Arm::NumLiteral.new( arg )
end
if( arg.is_a? Vm::Signed ) #HACK to not have to change the code just now
if( arg.is_a? Vm::Integer ) #HACK to not have to change the code just now
arg = Arm::NumLiteral.new( arg.value )
end
if (arg.is_a?(Arm::NumLiteral))

View File

@ -50,7 +50,7 @@ module Arm
raise "reference offset too large/small (max 4095) #{arg} #{inspect}"
end
end
elsif (arg.is_a?(Vm::StringLiteral)) #use pc relative
elsif (arg.is_a?(Vm::StringConstant)) #use pc relative
@rn = :pc
@operand = arg.position - self.position - 8 #stringtable is after code
@add_offset = 1