Sha256: d0a01cc5567612f40d888f61c641ce1f441cb0e28edddabc92420d72a51dde5d
Contents?: true
Size: 667 Bytes
Versions: 1
Compression:
Stored size: 667 Bytes
Contents
# frozen_string_literal: true module Tataru module Instructions # goto if temp result is non zero class GotoIfInstruction < ImmediateModeInstruction def run return if memory.hash[:temp][:result].zero? memory.program_counter = if @param.is_a? Integer @param - 1 else label_branch! end end def label_branch! unless memory.hash[:labels]&.key?(@param) raise "Label '#{@param}' not found" end memory.hash[:labels][@param] - 1 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tataru-0.2.0 | lib/tataru/instructions/goto_if_instruction.rb |