Fix word offset
which had weirdly been 1 off (not weird that it was off, index bugs are common, but weird that the tests passed anyway)
This commit is contained in:
parent
d901c6f27c
commit
915a1b5e90
@ -147,8 +147,8 @@ module Arm
|
|||||||
send( name , int_code )
|
send( name , int_code )
|
||||||
end
|
end
|
||||||
|
|
||||||
def putstring( int_code )
|
def putstring( int_code ) # adjust for object header (0 based, hence -1)
|
||||||
codes = ArmMachine.add( :r1 , :r1 , Parfait::Word.type_length*4 ) # adjust for object header
|
codes = ArmMachine.add( :r1 , :r1 , (Parfait::Word.type_length - 1)*4 )
|
||||||
codes.append ArmMachine.mov( :r0 , 1 ) # write to stdout == 1
|
codes.append ArmMachine.mov( :r0 , 1 ) # write to stdout == 1
|
||||||
syscall(int_code , codes )
|
syscall(int_code , codes )
|
||||||
end
|
end
|
||||||
|
@ -139,7 +139,7 @@ module Parfait
|
|||||||
raise "index not integer #{at.class}" unless at.is_a?(::Integer)
|
raise "index not integer #{at.class}" unless at.is_a?(::Integer)
|
||||||
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 + 8 # type_length * 4
|
return index + Word.type_length * 4
|
||||||
end
|
end
|
||||||
|
|
||||||
# compare the word to another
|
# compare the word to another
|
||||||
|
@ -98,10 +98,10 @@ module Parfait
|
|||||||
assert_raises {one.set_char(3 , "s".ord)}
|
assert_raises {one.set_char(3 , "s".ord)}
|
||||||
end
|
end
|
||||||
def test_max
|
def test_max
|
||||||
str = "123456789012345678901234"
|
str = "12345678901234567890"
|
||||||
one = Parfait.new_word(str)
|
one = Parfait.new_word(str)
|
||||||
assert_equal str , one.to_string
|
assert_equal str , one.to_string
|
||||||
assert_equal 24 , one.length
|
assert_equal 20 , one.length
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user