fix word indexes on arm

which affected offsets in the ruby side too
the hidden dead word needed accounting for
This commit is contained in:
Torsten Ruger 2015-11-19 16:40:00 +02:00
parent a8453c126d
commit aabde4b9a6
4 changed files with 14 additions and 15 deletions

View File

@ -139,7 +139,7 @@ module Parfait
index = self.length + at if at < 0 index = self.length + at if at < 0
raise "index must be positive , not #{at}" if (index <= 0) raise "index must be positive , not #{at}" if (index <= 0)
raise "index too large #{at} > #{self.length}" if (index > self.length ) raise "index too large #{at} > #{self.length}" if (index > self.length )
return index + Word.get_length_index * 4 return index + Word.get_length_index * 4 + 4
end end
# compare the word to another # compare the word to another

View File

@ -1,11 +1,11 @@
class Word < Object class Word < Object
int correct_index(int index) int _internal_index(int index)
return index + 8 return index + 12
end end
int char_at(int index) int get_char_at(int index)
index = correct_index(index) index = _internal_index(index)
return get_internal_byte(index) return get_internal_byte(index)
end end
@ -15,7 +15,7 @@ class Word < Object
end end
int set_char_at( int index , int val) int set_char_at( int index , int val)
index = correct_index(index) index = _internal_index(index)
return set_internal_byte(index , val) return set_internal_byte(index , val)
end end

View File

@ -52,7 +52,6 @@ module RuntimeTests
def check_remote ret def check_remote ret
return unless box = connected return unless box = connected
return unless ret.is_a?(Numeric)
file = write_object_file file = write_object_file
r_file = file.sub("./" , "salama/") r_file = file.sub("./" , "salama/")
box.file_upload file , r_file box.file_upload file , r_file
@ -64,7 +63,7 @@ module RuntimeTests
end end
assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout
assert_equal "" , ret.stderr.join , "remote had error" assert_equal "" , ret.stderr.join , "remote had error"
if ret if ret and ret.is_a?(Numeric)
should = @interpreter.get_register(:r0).return_value should = @interpreter.get_register(:r0).return_value
should &= 0xFF # don't knwo why exit codes are restricted but there you are should &= 0xFF # don't knwo why exit codes are restricted but there you are
assert_equal should , ret.exit_status.to_i , "remote exit failed for #{@string_input}" assert_equal should , ret.exit_status.to_i , "remote exit failed for #{@string_input}"
@ -72,7 +71,7 @@ module RuntimeTests
end end
def write_object_file def write_object_file
file_name = caller(3).first.split("in ").last.chop.sub("`","") file_name = caller(4).first.split("in ").last.chop.sub("`","")
return if file_name.include?("run") return if file_name.include?("run")
file_name = "./tmp/" + file_name + ".o" file_name = "./tmp/" + file_name + ".o"
Register.machine.translate_arm Register.machine.translate_arm

View File

@ -14,7 +14,7 @@ HERE
def test_space def test_space
@main = <<HERE @main = <<HERE
Word w = " " Word w = " "
return w.char_at(1) return w.get_char_at(1)
HERE HERE
assert_equal 32 , " ".codepoints[0] # just checking assert_equal 32 , " ".codepoints[0] # just checking
check_return 32 check_return 32
@ -24,7 +24,7 @@ HERE
@main = <<HERE @main = <<HERE
Word w = " " Word w = " "
w.push_char(48) w.push_char(48)
return w.char_at(1) return w.get_char_at(1)
HERE HERE
check_return 32 check_return 32
end end
@ -33,7 +33,7 @@ HERE
@main = <<HERE @main = <<HERE
Word w = " " Word w = " "
w.push_char(48) w.push_char(48)
return w.char_at(2) return w.get_char_at(2)
HERE HERE
check_return 48 check_return 48
end end
@ -50,7 +50,7 @@ HERE
def test_get1 def test_get1
@main = <<HERE @main = <<HERE
Word w = "12345" Word w = "12345"
return w.char_at(1) return w.get_char_at(1)
HERE HERE
check_return 49 check_return 49
end end
@ -58,7 +58,7 @@ HERE
def test_get2 def test_get2
@main = <<HERE @main = <<HERE
Word w = "12345" Word w = "12345"
return w.char_at(2) return w.get_char_at(2)
HERE HERE
check_return 50 check_return 50
end end
@ -67,7 +67,7 @@ HERE
@main = <<HERE @main = <<HERE
Word w = "12345" Word w = "12345"
w.set_char_at(2 , 51) w.set_char_at(2 , 51)
return w.char_at(2) return w.get_char_at(2)
HERE HERE
check_return 51 check_return 51
end end