From 0fa47d204e82ad8777ba9ed01d663eb1e6fa621a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 20 May 2014 10:28:34 +0300 Subject: [PATCH] minor --- lib/core/kernel.rb | 6 +++--- lib/elf/object_writer.rb | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/core/kernel.rb b/lib/core/kernel.rb index 379ad1f1..65bbd423 100644 --- a/lib/core/kernel.rb +++ b/lib/core/kernel.rb @@ -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) diff --git a/lib/elf/object_writer.rb b/lib/elf/object_writer.rb index e16d1e94..4f21161d 100644 --- a/lib/elf/object_writer.rb +++ b/lib/elf/object_writer.rb @@ -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