How many lies do I have to argue against?
http://dkrizanc.web.wesleyan.edu/courses/231/07/mips-spim.pdf
MIPS Assembly Language Programming
Page 49:
2. The callee must, as part of the function preamble:
(a) Create a stack frame, by subtracting the frame size from the stack
pointer ($sp).
Note that the minimum stack frame size in the MIPS software architecture
is 32 bytes, so even if you don't need all of this space, you should
still make your stack frames this large.
When the stack register is assigned by the OS ABI, that means it's not
a ``hardware'' stack.
No, a HARDWARE register is a software stack
WORD GAMES AND WORD GAMES. Regular do not know anything else
At least it is fun!!
Only a software stack is needed for this.
Some RISC processors only save minimal information to be able to
return from a subroutine call. That information is the return address,
and it goes into a register. Returning from the subroutine is done by
branching to the address stored in that register. No stack is
involved.
The power PC (the archetypal RISC) has a dedicated register
for maintaining the stack. (register 2 if I remeber correctly)
WRONG AGAIN!
This simply requires a modified jump instruction which specifies a
register where the instruction pointer is stored. A regular indirect
jump is then used to perform the return.
From the CINT documentation:
``[E]very object created by CINT is a heap object so CINT does not
need the distinction between heap and stack based objects.''
This produces that CINT is not C...
<quote>
# Scope:
+ Function scope
Variables can be declared in global or function scope.
Unlike ANSI, local variable has function scope. If a local variable is
once declared in a function, it will be alive until execution gets out
from the function even if it is declared within sub-block. In ANSI C,
local
variables have block scope.
void func()
{
int i;
for(i=0;i<10;i++) {
int n; /* block scope */
printf("n=%d\\n",n++);
}
/* n is still alive here in cint, n should be already
dead in ANSI C */
}
<end quote>
That's the problem with not having a stack maybe.
Baloney. The above issue has nothing to do with stacks. It's simply a
parsing and name lookup issue. A conforming C compiler can let you
access n outside of the block where it is defined, provided that a
diagnostic is issued.
It's perfectly legitimate to treat an entire function scope as one
unit, such that all local variables are given unique locations within
the corresponding activation frame.
The simplest possible algorithm is to simply allocate local variables
in one big frame as the function body is parsed top to bottom.
Whenever a new declaration is parsed, regardless of the block scope in
which it appears, space is set aside and an entry is made under that
name in a symbol table. A name reference goes to the most recent
definition.
For conformance, all you need is to mark definitions out of scope so
that you can diagnose dangling name references.
C doesn't have true lexical scope (i.e. lexical closures) so issues of
instantiation of block scope locals don't matter.
If you could create a lexical closure within that for loop, then it
would matter, because on each iteration, your closure would want to
capture a different instance of n, yet each of these closures would
share the same instance of i.
(Needless to say, a C dialect supporting lexical closures wouldn't be
able to use a conventional flat stack for automatic storage).
.. ANSI C requires a stack.
Except for the problem that the document doesn't even use the word. Of
course ISO C requires automatic storage: a way to have fresh instances
of local variables, and a way to remember how to get back to the
suspended parent function.
We can't really call this a stack, because not all instances of it
require anything like it.
For instance a trivial leaf function might be compiled into code that
uses registers for representing all local variables (including
incoming parameters), and which returns by branching to an address
which also came in a register, and which passes back a return value in
a register. Such a function effectively has no stack frame (even
though other functions in the same program might have one).
In the abstract language, though, the function has automatic storage.
In comp.lang.c we emphasize the abstract language, because this is the
best way to serve the needs of newbies in their quest for
enlightenment. They are confused by thoughts like ``there is something
called a stack, and a function always has a stack frame''.
Other problems arise with variable argument functions.
Actually if you read it carefully, the issues are with foreign calls
to compiled variadic functions. For that to work, an architecture-
specific frame has to be generated. If you're calling something that
expects a stack, by golly, you have to set one up.
It doesn't appear to be an internal issue with CINT interpreted
funtions calling variadic CINT functions.
For the long
list of non standard features seehttp://root.cern.ch/viewcvs/trunk/doc/limitati.txt?root=cint
It's actually quite a short list, which took only a few minutes to
read.
Conclusion: This implementation is an embedded interpreter that
is not really standard. It shows how necessary a stack is for
a full implementation of C since many of the incompatibilities
arise from this fact.
Outlandish claim.
Except for the foreign calling considerations, none of the other
issues in that list appear to be even remotely connected to how CINT
represents automatic storage.