Module: HackAssembler::AInstruction
- Defined in:
- lib/hack_assembler/a_instruction.rb
Class Method Summary collapse
Class Method Details
.translate(instruction) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/hack_assembler/a_instruction.rb', line 3 def self.translate(instruction) matched = /@([0-9]+)/.match(instruction) raise ParserError if matched.nil? value = matched[1].to_i binary_value = value.to_s(2) padded_binary_value = binary_value.rjust(16, '0') padded_binary_value end |