class Assembler::Instructions::AddressInstruction
Public Class Methods
new(instruction, symbol_table)
click to toggle source
# File lib/hackasm/assembler/instructions/address_instruction.rb, line 4 def initialize(instruction, symbol_table) @instruction = instruction.compact.map { |key, value| [key, value.to_s] }.to_h @symbol_table = symbol_table end
Public Instance Methods
to_b()
click to toggle source
# File lib/hackasm/assembler/instructions/address_instruction.rb, line 9 def to_b if memory_address = @instruction[:memory_address] memory_address.to_i elsif identifier = @instruction[:identifier] @symbol_table[identifier] end.to_s(2).rjust(16, '0') end