use logger

This commit is contained in:
Torsten Ruger 2015-11-05 16:50:00 +02:00
parent 13d0747b45
commit 4eb3d9029a

View File

@ -5,6 +5,8 @@ module Interpreter
class Interpreter class Interpreter
# fire events for changed pc and register contents # fire events for changed pc and register contents
include Eventable include Eventable
include Logging
log_level :info
attr_reader :instruction # current instruction or pc attr_reader :instruction # current instruction or pc
attr_reader :clock # current instruction or pc attr_reader :clock # current instruction or pc
@ -59,7 +61,7 @@ module Interpreter
@flags[:zero] = (val == 0) @flags[:zero] = (val == 0)
@flags[:plus] = (val > 0) @flags[:plus] = (val > 0)
@flags[:minus] = (val < 0) @flags[:minus] = (val < 0)
#puts "Set_flags #{val} :#{@flags.inspect}" log.debug "Set_flags #{val} :#{@flags.inspect}"
else else
@flags[:zero] = @flags[:plus] = true @flags[:zero] = @flags[:plus] = true
@flags[:minus] = false @flags[:minus] = false
@ -74,7 +76,7 @@ module Interpreter
return unless @instruction return unless @instruction
@clock += 1 @clock += 1
name = @instruction.class.name.split("::").last name = @instruction.class.name.split("::").last
#puts @instruction log.debug @instruction
fetch = send "execute_#{name}" fetch = send "execute_#{name}"
return unless fetch return unless fetch
set_instruction @instruction.next set_instruction @instruction.next
@ -171,7 +173,7 @@ module Interpreter
end end
def execute_OperatorInstruction def execute_OperatorInstruction
#puts @instruction log.debug @instruction
left = get_register(@instruction.left) left = get_register(@instruction.left)
rr = @instruction.right rr = @instruction.right
right = get_register(rr) right = get_register(rr)
@ -190,7 +192,7 @@ module Interpreter
else else
raise "unimplemented '#{@instruction.operator}' #{@instruction}" raise "unimplemented '#{@instruction.operator}' #{@instruction}"
end end
#puts "#{@instruction} == #{result} (#{left}|#{right})" log.debug "#{@instruction} == #{result} (#{left}|#{right})"
right = set_register(@instruction.left , result) right = set_register(@instruction.left , result)
true true
end end