Class: RPicSim::StackPointer

Inherits:
Object
  • Object
show all
Defined in:
lib/rpicsim/stack_pointer.rb

Overview

Instances of this class represent the call stack pointer in a running simulation. A value of 0 means that the stack is empty, regardless of what device architecture you are simulating.

Instance Method Summary collapse

Instance Method Details

#valueInteger

Returns:

  • (Integer)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rpicsim/stack_pointer.rb', line 21

def value
  if @stkptr_initial_value > 0
    raw_value = @stkptr.value
    if raw_value == @stkptr_initial_value
      0
    else
      raw_value + 1
    end
  else
    @stkptr.value
  end
end

#value=(value) ⇒ Object

Parameters:

  • value (Integer)


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rpicsim/stack_pointer.rb', line 35

def value=(value)
  @stkptr.value = if @stkptr_initial_value > 0
                    if value == 0
                      @stkptr_initial_value
                    else
                      value - 1
                    end
                  else
                    value
                  end
end