fix dunamic jump in interpreter and misc

This commit is contained in:
Torsten Ruger 2018-07-03 19:15:36 +03:00
parent cab6bc389f
commit e099014d63
6 changed files with 10 additions and 7 deletions

View File

@ -57,7 +57,7 @@ module Arm
end end
def to_s def to_s
"#{opcode} [#{@first.join(',') }] #{super}" "#{opcode} [#{@first.join(', ') }] #{super}"
end end
end end

View File

@ -30,7 +30,7 @@ module Mom
def to_s def to_s
names = [known_name] + @slots names = [known_name] + @slots
"[#{names.join(',')}]" "[#{names.join(', ')}]"
end end
def known_name def known_name

View File

@ -16,6 +16,7 @@ module Risc
str = label.name str = label.name
when Parfait::BinaryCode when Parfait::BinaryCode
str = "Code" str = "Code"
str += ":#{Position.get(label)}" if Position.set?(label)
else else
str = "(no label)" str = "(no label)"
end end

View File

@ -32,7 +32,8 @@ module Risc
@linker = linker @linker = linker
end end
def start_program def start_program(linker = nil)
@linker = linker || @linker
initialize(@linker) initialize(@linker)
init = @linker.cpu_init init = @linker.cpu_init
set_state(:running) set_state(:running)
@ -115,14 +116,15 @@ module Risc
# Instruction interpretation starts here # Instruction interpretation starts here
def execute_DynamicJump def execute_DynamicJump
method = get_register(@instruction.register) method = get_register(@instruction.register)
set_pc( Position.get(method.cpu_instructions).at ) pos = Position.get(method.binary).at + Parfait::BinaryCode.byte_offset
set_pc( pos )
false false
end end
def execute_Branch def execute_Branch
label = @instruction.label label = @instruction.label
pos = Position.get(label).at pos = Position.get(label).at
pos += Parfait::BinaryCode.byte_offset if label.is_a?(Parfait::BinaryCode) pos += Parfait::BinaryCode.byte_offset if label.is_a?(Parfait::BinaryCode)
set_pc pos set_pc( pos )
false false
end end

View File

@ -52,7 +52,7 @@ module Vool
end end
def to_s def to_s
"#{receiver}.#{name}(#{arguments.join(',')})" "#{receiver}.#{name}(#{arguments.join(', ')})"
end end
def each(&block) def each(&block)
block.call(self) block.call(self)

View File

@ -33,7 +33,7 @@ module Vool
end end
def to_s def to_s
"#{receiver}.#{name}(#{arguments.join(',')})" "#{receiver}.#{name}(#{arguments.join(', ')})"
end end
def each(&block) def each(&block)
block.call(self) block.call(self)