Shop OBEX P1 Docs P2 Docs Learn Events
Stack overflow checking?? — Parallax Forums

Stack overflow checking??

Harry1Harry1 Posts: 29
edited 2007-02-01 22:19 in Propeller 1
Does the propeller chip perform stack overflow checking?

thanks in advance

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-19 03:54
    No it does not. Strictly speaking, the Propeller chip doesn't have a stack. The Spin interpreter is a program built into the ROM that interprets byte code instructions for a stack machine. In any event, the interpreter only checks for underflow. You can do your own near-overflow checking by getting the address of a local variable in some method and comparing it to the end of the stack. For example:
    PRI checkStack | local
      if $8000 - @local < 256
         abort  ' There are less than 256 bytes left in the main stack
    
    
  • asterickasterick Posts: 158
    edited 2007-01-19 04:00
    Neat trick. [noparse]:)[/noparse]
  • Harry1Harry1 Posts: 29
    edited 2007-02-01 22:02
    okay, thank you!
  • rokickirokicki Posts: 1,000
    edited 2007-02-01 22:19
    Instead of requiring a local, you can just use result:

    pub somemethod
       if $8000 - @result < 256
          abort(string("Out of stack"))
    
    
Sign In or Register to comment.