class RPicSim::StackPointer
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.
@api public
Public Class Methods
new(stkptr)
click to toggle source
Initializes the StackPointer
object. This be called when the call stack is empty, because this object uses the initial value of stkptr to deduce how it works. @param stkptr The STKPTR register of the simulation. @api private
# File lib/rpicsim/stack_pointer.rb, line 15 def initialize(stkptr) @stkptr = stkptr @stkptr_initial_value = @stkptr.value end
Public Instance Methods
value()
click to toggle source
@return [Integer]
# 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)
click to toggle source
@param value [Integer]
# 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