From f50d7b57a45135a6ab1fa0b28235e4559b8e73db Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 15 Nov 2015 22:03:06 +0200 Subject: [PATCH] fix the putstring sys call indexing index 0 is the marker word , so like in some, all indexes 1 based works :-) --- Gemfile.lock | 2 +- lib/arm/translator.rb | 5 ++--- lib/register/builtin/kernel.rb | 1 - test/elf/test_hello.rb | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c32276c1..24828ed9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/salama/salama-arm.git - revision: 72fcf371bc42279676533142c82e34713e77ea75 + revision: c711d34418f08bb2d7c5fea3cbe4149bdd22aa61 specs: salama-arm (0.3.0) diff --git a/lib/arm/translator.rb b/lib/arm/translator.rb index 5d3209be..f2e14f4f 100644 --- a/lib/arm/translator.rb +++ b/lib/arm/translator.rb @@ -128,9 +128,8 @@ module Arm end def putstring int_code - codes = ArmMachine.ldr( :r1 , Register.message_reg, 4 * Register.resolve_index(:message , :receiver) - 4) - codes.append ArmMachine.ldr( :r2 , :r1 , 4 ) # String length - codes.append ArmMachine.add( :r1 , :r1 , 8 ) # adjust for object header + codes = ArmMachine.ldr( :r2 , :r1 , 8 ) # String length + codes.append ArmMachine.add( :r1 , :r1 , 12 ) # adjust for object header codes.append ArmMachine.mov( :r0 , 1 ) # write to stdout == 1 syscall(int_code , codes ) end diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index eb965f4a..aefaa40a 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -66,7 +66,6 @@ module Register compiler.add_code RegisterTransfer.new(source, r8 , Register.message_reg ) # save the return value into the message compiler.add_code Register.set_slot( source , return_tmp , :message , :return_value ) - # and "unroll" self and frame end end extend ClassMethods diff --git a/test/elf/test_hello.rb b/test/elf/test_hello.rb index 01043e2b..3fdb69fd 100644 --- a/test/elf/test_hello.rb +++ b/test/elf/test_hello.rb @@ -15,7 +15,7 @@ class HelloTest < MiniTest::Test @string_input = <