just keep binary code payload at 13 for now
there is an extra in there at the last of the last, but ok
This commit is contained in:
parent
231025389a
commit
1e21177b35
@ -12,15 +12,15 @@ module Parfait
|
|||||||
def initialize(total_size)
|
def initialize(total_size)
|
||||||
super()
|
super()
|
||||||
if total_size > self.data_length
|
if total_size > self.data_length
|
||||||
@next = BinaryCode.new(total_size - data_length - 1) #one for the jump
|
@next = BinaryCode.new(total_size - data_length) #one for the jump
|
||||||
end
|
end
|
||||||
#puts "Init with #{total_size} for #{object_id}"
|
puts "Init with #{total_size} for #{object_id}"
|
||||||
end
|
end
|
||||||
def to_s
|
def to_s
|
||||||
"BinaryCode #{}"
|
"BinaryCode #{}"
|
||||||
end
|
end
|
||||||
def data_length
|
def data_length
|
||||||
14
|
13
|
||||||
end
|
end
|
||||||
def byte_length
|
def byte_length
|
||||||
4*data_length
|
4*data_length
|
||||||
@ -36,7 +36,7 @@ module Parfait
|
|||||||
set_internal_word(word_index , char)
|
set_internal_word(word_index , char)
|
||||||
end
|
end
|
||||||
def total_byte_length(start = 0 )
|
def total_byte_length(start = 0 )
|
||||||
start += 4*14
|
start += self.byte_length
|
||||||
return start unless self.next
|
return start unless self.next
|
||||||
self.next.total_byte_length(start)
|
self.next.total_byte_length(start)
|
||||||
end
|
end
|
||||||
|
@ -160,7 +160,7 @@ module Risc
|
|||||||
binary = method.binary
|
binary = method.binary
|
||||||
total_byte_length = method.cpu_instructions.total_byte_length
|
total_byte_length = method.cpu_instructions.total_byte_length
|
||||||
log.debug "Assembled code #{method.name} with length #{length}"
|
log.debug "Assembled code #{method.name} with length #{length}"
|
||||||
raise "length error #{binary.char_length} != #{total_byte_length}" if binary.char_length <= total_byte_length
|
raise "length error #{binary.total_byte_length} != #{total_byte_length}" if binary.total_byte_length <= total_byte_length
|
||||||
raise "length error #{length} != #{total_byte_length}" if total_byte_length != length
|
raise "length error #{length} != #{total_byte_length}" if total_byte_length != length
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ module Risc
|
|||||||
translator.translate( self )
|
translator.translate( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
def assemble_all io , labels = []
|
def assemble_all( io , labels = [] )
|
||||||
self.assemble(io)
|
self.assemble(io)
|
||||||
self.next.assemble_all(io, labels) if self.next
|
self.next.assemble_all(io, labels) if self.next
|
||||||
end
|
end
|
||||||
@ -55,7 +55,7 @@ module Risc
|
|||||||
raise "Abstract called on #{self}"
|
raise "Abstract called on #{self}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_byte_length labels = []
|
def total_byte_length( labels = [])
|
||||||
ret = self.byte_length
|
ret = self.byte_length
|
||||||
ret += self.next.total_byte_length(labels) if self.next
|
ret += self.next.total_byte_length(labels) if self.next
|
||||||
#puts "#{self.class.name} return #{ret}"
|
#puts "#{self.class.name} return #{ret}"
|
||||||
|
@ -24,10 +24,14 @@ module Parfait
|
|||||||
assert_nil @code.next
|
assert_nil @code.next
|
||||||
end
|
end
|
||||||
def test_data_length
|
def test_data_length
|
||||||
assert_equal 14 , @code.data_length
|
assert_equal 13 , @code.data_length
|
||||||
end
|
end
|
||||||
def test_byte_length
|
def test_byte_length
|
||||||
assert_equal 14*4 , @code.byte_length
|
assert_equal 13*4 , @code.byte_length
|
||||||
|
end
|
||||||
|
def test_total_byte_length
|
||||||
|
@code = BinaryCode.new(16)
|
||||||
|
assert_equal 13*4*2 , @code.total_byte_length
|
||||||
end
|
end
|
||||||
def test_next_not_nil
|
def test_next_not_nil
|
||||||
@code = BinaryCode.new(16)
|
@code = BinaryCode.new(16)
|
||||||
@ -37,11 +41,11 @@ module Parfait
|
|||||||
def test_set_char1
|
def test_set_char1
|
||||||
assert @code.set_char(1 , 1)
|
assert @code.set_char(1 , 1)
|
||||||
end
|
end
|
||||||
def test_set_char55
|
def test_set_char51
|
||||||
assert @code.set_char(55 , 1)
|
assert @code.set_char(51 , 1)
|
||||||
end
|
end
|
||||||
def test_set_char56_raises
|
def test_set_char52_raises
|
||||||
assert_raises {@code.set_char(56 , 1)}
|
assert_raises {@code.set_char(52 , 1)}
|
||||||
end
|
end
|
||||||
def test_set_char56_double
|
def test_set_char56_double
|
||||||
@code = BinaryCode.new(16)
|
@code = BinaryCode.new(16)
|
||||||
|
Loading…
Reference in New Issue
Block a user