class Tataru::Instructions::GotoIfInstruction
goto if temp result is non zero
Public Instance Methods
label_branch!()
click to toggle source
# File lib/tataru/instructions/goto_if_instruction.rb, line 17 def label_branch! unless memory.hash[:labels]&.key?(@param) raise "Label '#{@param}' not found" end memory.hash[:labels][@param] - 1 end
run()
click to toggle source
# File lib/tataru/instructions/goto_if_instruction.rb, line 7 def run return if memory.hash[:temp][:result].zero? memory.program_counter = if @param.is_a? Integer @param - 1 else label_branch! end end