Method: MicroCisc::Compile::Instruction#validate_alu

Defined in:
lib/micro_cisc/compile/instruction.rb

#validate_alu(component, current) ⇒ Object

Raises:

  • (ArgumentError)


120
121
122
123
124
125
126
127
# File 'lib/micro_cisc/compile/instruction.rb', line 120

def validate_alu(component, current)
  raise ArgumentError, "Duplicate #{component.last} value" if current
  code = component.first
  unless code >= 0 && code < 16
    raise ArgumentError, "Value of #{component.last} must be between 0x0 and 0xF instead of 0x#{component.first.to_s(16).upcase}"
  end
  component.first
end