Class: AVR::RegisterPair

Inherits:
Register show all
Extended by:
T::Sig
Defined in:
lib/avr/register/register_pair.rb

Direct Known Subclasses

SP

Instance Attribute Summary collapse

Attributes inherited from Register

#cpu

Attributes inherited from Value

#name

Instance Method Summary collapse

Methods inherited from Value

#inspect, #to_i, #to_s, #value_hex

Constructor Details

#initialize(cpu, l, h, name = nil) ⇒ RegisterPair

Returns a new instance of RegisterPair.



23
24
25
26
27
# File 'lib/avr/register/register_pair.rb', line 23

def initialize(cpu, l, h, name = nil)
  super(cpu, name || "Temporary[#{l.name}, #{h.name}]")
  @l = l
  @h = h
end

Instance Attribute Details

#hObject (readonly)

Returns the value of attribute h.



13
14
15
# File 'lib/avr/register/register_pair.rb', line 13

def h
  @h
end

#lObject (readonly)

Returns the value of attribute l.



10
11
12
# File 'lib/avr/register/register_pair.rb', line 10

def l
  @l
end

Instance Method Details

#formatObject



30
31
32
# File 'lib/avr/register/register_pair.rb', line 30

def format
  '%04x'
end

#valueObject



35
36
37
# File 'lib/avr/register/register_pair.rb', line 35

def value
  (h.value << 8) | l.value
end

#value=(new_value) ⇒ Object



40
41
42
43
# File 'lib/avr/register/register_pair.rb', line 40

def value=(new_value)
  h.value = (new_value & 0xff00) >> 8
  l.value = (new_value & 0x00ff)
end