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

@ -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