[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: stack indexing confusion
- From: "David McClurg" <dmcclurg@...>
- Date: Fri, 16 Aug 2002 13:40:52 +1000
Just wanted to mention that several people here were initially confused about stack indexing. The manual says:
5.2 - The Stack and Indices
A positive index represents an absolute stack position (starting at 1, not 0 as in C); a negative index represents an offset from the top of the stack.
Nowhere does it mention anything about the stack frame (call base) for a function. After looking at some examples you realize that index 1 is your first argument in a function call but that was not immediately obvious. I think this should be mentioned in section 5.2 or any new manuals.
lapi.c: #define Index(L,i) ((i) >= 0 ? (L->Cbase+((i)-1)) : (L->top+(i)))