getting better, but somethings off

This commit is contained in:
Torsten Ruger
2014-05-05 09:35:40 +03:00
parent a61170942f
commit 7c0aa8ae7d
10 changed files with 138 additions and 51 deletions

View File

@ -30,11 +30,14 @@ module Arm
end
end
def word_load value
"word"
def word_load value , reg
e = Vm::Block.new("load_#{value}")
e.add_code( MoveInstruction.new( :left => reg , :right => value ) )
end
def function_call call_value
"call"
def function_call call
raise "Not FunctionCall #{call.inspect}" unless call.is_a? Vm::FunctionCall
e = Vm::Block.new("call_#{call.name}")
e.add_code( bl( :function => call.function ))
end
def main_entry
@ -47,8 +50,8 @@ module Arm
end
def syscall num
e = Vm::Block.new("syscall")
e.add_code( MoveInstruction.new( 7 , num ) )
e.add_code( CallInstruction.new( :swi ) )
e.add_code( MoveInstruction.new( :left => 7 , :right => num ) )
e.add_code( CallInstruction.new( :swi => 0 ) )
e
end
end