Module: Raudi::Source::BitOperations

Included in:
Base
Defined in:
lib/raudi/source/bit_operations.rb

Instance Method Summary collapse

Instance Method Details

#clear_register(register_name, bits) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/raudi/source/bit_operations.rb', line 16

def clear_register(register_name, bits)
  unless bits.empty?
    source = register_name.to_s.upcase
    source << " &= "
    source << "~("
    source << join_bits(bits)
    source << ")"
    code_line(source)
  end
end

#join_bits(bits) ⇒ Object



27
28
29
# File 'lib/raudi/source/bit_operations.rb', line 27

def join_bits(bits)
  bits.map{|bit| "1 << #{bit}"}.join(" | ")
end

#write_register(register_name, bits) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/raudi/source/bit_operations.rb', line 7

def write_register(register_name, bits)
  unless bits.empty?
    source = register_name.to_s.upcase
    source << " |= "
    source << join_bits(bits)
    code_line(source)
  end
end