thats putstring working again (better testing == better code => better sleep, longer life :-)

This commit is contained in:
Torsten Ruger 2014-05-21 21:27:05 +03:00
parent 587fd56300
commit e3bccaa0fe
3 changed files with 10 additions and 3 deletions

View File

@ -94,7 +94,14 @@ module Vm
end end
def load block , right 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 self
end end

View File

@ -33,7 +33,7 @@ module Fragments
assembly = writer.text assembly = writer.text
# use this for getting the bytes to compare to : # use this for getting the bytes to compare to :
#puts assembly #puts assembly
writer.save("#{name}_test.o") writer.save("#{name}.o")
assembly.text.bytes.each_with_index do |byte , index| assembly.text.bytes.each_with_index do |byte , index|
is = @should[index] is = @should[index]
assert_equal Fixnum , is.class , "@#{index.to_s(16)} = #{is}" assert_equal Fixnum , is.class , "@#{index.to_s(16)} = #{is}"

View File

@ -8,7 +8,7 @@ class TestHello < MiniTest::Test
@string_input = <<HERE @string_input = <<HERE
putstring( "Hello Raisa, I am crystksdfkljsncjncn" ) putstring( "Hello Raisa, I am crystksdfkljsncjncn" )
HERE HERE
@should = [0x0,0xb0,0xa0,0xe3,0xe,0x0,0x2d,0xe9,0x28,0x0,0xaf,0xe3,0x2,0x0,0x0,0xeb,0xe,0x0,0xbd,0xe8,0x1,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x40,0x2d,0xe9,0x1,0x20,0xa0,0xe1,0x0,0x10,0xa0,0xe1,0x1,0x0,0xa0,0xe3,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x80,0xbd,0xe8,0x48,0x65,0x6c,0x6c,0x6f,0x20,0x52,0x61,0x69,0x73,0x61,0x2c,0x20,0x49,0x20,0x61,0x6d,0x20,0x63,0x72,0x79,0x73,0x74,0x6b,0x73,0x64,0x66,0x6b,0x6c,0x6a,0x73,0x6e,0x63,0x6a,0x6e,0x63,0x6e,0x0,0x0,0x0] @should = [0x0,0xb0,0xa0,0xe3,0xe,0x0,0x2d,0xe9,0x2c,0x0,0x8f,0xe2,0x28,0x10,0xa0,0xe3,0x2,0x0,0x0,0xeb,0xe,0x0,0xbd,0xe8,0x1,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x40,0x2d,0xe9,0x1,0x20,0xa0,0xe1,0x0,0x10,0xa0,0xe1,0x1,0x0,0xa0,0xe3,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x80,0xbd,0xe8,0x48,0x65,0x6c,0x6c,0x6f,0x20,0x52,0x61,0x69,0x73,0x61,0x2c,0x20,0x49,0x20,0x61,0x6d,0x20,0x63,0x72,0x79,0x73,0x74,0x6b,0x73,0x64,0x66,0x6b,0x6c,0x6a,0x73,0x6e,0x63,0x6a,0x6e,0x63,0x6e,0x0,0x0,0x0]
parse parse
write "hello" write "hello"
end end