make binary code indexed (not derive from word)
still some work to be done there, as we should really have a byte buffer
This commit is contained in:
parent
96f43dcfda
commit
1a236aa50e
@ -9,18 +9,17 @@
|
|||||||
module Parfait
|
module Parfait
|
||||||
# obviously not a "Word" but a ByteArray , but no such class yet
|
# obviously not a "Word" but a ByteArray , but no such class yet
|
||||||
# As on the other hand has no encoding (yet) it is close enough
|
# As on the other hand has no encoding (yet) it is close enough
|
||||||
class BinaryCode < Word
|
class BinaryCode < Object
|
||||||
def initialize name
|
|
||||||
super(0)
|
|
||||||
self.name = name
|
|
||||||
end
|
|
||||||
attribute :name
|
attribute :name
|
||||||
|
|
||||||
# this is a sof check if there are instance variables or "structure"
|
include Indexed
|
||||||
# have to override false, as word answers true
|
self.offset(2)
|
||||||
def is_value?
|
|
||||||
false
|
def initialize name
|
||||||
|
super()
|
||||||
|
self.name = name
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"BinaryCode #{self.name}"
|
"BinaryCode #{self.name}"
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ module Register
|
|||||||
@machine.objects.each do |id , objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::Method
|
next unless objekt.is_a? Parfait::Method
|
||||||
# should be fill_to_length (with zeros)
|
# should be fill_to_length (with zeros)
|
||||||
objekt.binary.set_length(objekt.source.total_byte_length , 0)
|
objekt.binary.set_length(objekt.source.total_byte_length )
|
||||||
end
|
end
|
||||||
#need the initial jump at 0 and then functions
|
#need the initial jump at 0 and then functions
|
||||||
@machine.init.set_position(at)
|
@machine.init.set_position(at)
|
||||||
@ -112,14 +112,13 @@ module Register
|
|||||||
puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}"
|
puts "Assembly error #{method.name}\n#{Sof.write(method.source.instructions).to_s[0...2000]}"
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
method.binary.fill_with 0
|
|
||||||
index = 1
|
index = 1
|
||||||
stream.rewind
|
stream.rewind
|
||||||
#puts "Assembled #{method.name} with length #{stream.length}"
|
#puts "Assembled #{method.name} with length #{stream.length}"
|
||||||
raise "length error #{method.binary.length} != #{method.source.total_byte_length}" if method.binary.length != method.source.total_byte_length
|
raise "length error #{method.binary.length} != #{method.source.total_byte_length}" if method.binary.get_length != method.source.total_byte_length
|
||||||
raise "length error #{stream.length} != #{method.source.total_byte_length}" if method.source.total_byte_length != stream.length
|
raise "length error #{stream.length} != #{method.source.total_byte_length}" if method.source.total_byte_length != stream.length
|
||||||
stream.each_byte do |b|
|
stream.each_byte do |b|
|
||||||
method.binary.set_char(index , b )
|
method.binary.set(index , b )
|
||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user