diff --git a/lib/vm/values.rb b/lib/vm/values.rb index 4b1382bc..80b35b0a 100644 --- a/lib/vm/values.rb +++ b/lib/vm/values.rb @@ -94,7 +94,14 @@ module Vm end def load block , right - block.mov( self , right ) + if(right.is_a? IntegerConstant) + block.mov( self , right ) #move the value + elsif right.is_a? StringConstant + block.add( self , right , nil) #move the address, by "adding" to pc, ie pc relative + block.mov( Integer.new(register+1) , right.length ) #and the length HACK TODO + else + raise "unknown #{right.inspect}" + end self end diff --git a/test/fragments/helper.rb b/test/fragments/helper.rb index 9dd531c1..cb8eab60 100644 --- a/test/fragments/helper.rb +++ b/test/fragments/helper.rb @@ -33,7 +33,7 @@ module Fragments assembly = writer.text # use this for getting the bytes to compare to : #puts assembly - writer.save("#{name}_test.o") + writer.save("#{name}.o") assembly.text.bytes.each_with_index do |byte , index| is = @should[index] assert_equal Fixnum , is.class , "@#{index.to_s(16)} = #{is}" diff --git a/test/fragments/test_hello.rb b/test/fragments/test_hello.rb index d2b3a4e6..12e25a47 100644 --- a/test/fragments/test_hello.rb +++ b/test/fragments/test_hello.rb @@ -8,7 +8,7 @@ class TestHello < MiniTest::Test @string_input = <