This commit is contained in:
Torsten Ruger 2014-05-20 10:28:34 +03:00
parent f34fddd383
commit 0fa47d204e
2 changed files with 4 additions and 5 deletions

View File

@ -80,12 +80,11 @@ module Core
# not my hand off course, found in the net from a basic introduction
def fibo context
fibo_function = Vm::Function.new(:fibo , [Vm::Integer , Vm::Integer] , Vm::Integer )
result = fibo_function.args[0]
int =fibo_function.args[1]
result , int = fibo_function.args
i = Vm::Integer.new(2)
loop_block = Vm::Block.new("loop")
f1 = Vm::Integer.new(3)
f2 = Vm::Integer.new(4)
loop_block = Vm::Block.new("loop")
fibo_function.body.instance_eval do
cmp( int , 1)
mov( result, int , condition_code: :le)
@ -96,6 +95,7 @@ module Core
sub( i , int , 2)
add_code loop_block
end
loop_block.instance_eval do
add( f1 , f1 , f2)
sub( f2 , f1 , f2)

View File

@ -29,12 +29,11 @@ module Elf
end
set_text binary.string
end
attr_reader :text
def set_text(text)
@text.text = text
add_symbol "_start", 0
end
def add_symbol(name, offset, linkage = Elf::Constants::STB_GLOBAL)
@symbol_table.add_func_symbol name, offset, @text, linkage
end