Here is a quote from the book "Introduction to Assembly language" about RISC (vs CISC)
In MIPS, we could write procedures without using the stack. For most normal procedures, we do not have to use the stack. The availability of a large number of registers allows us to use register-based parameter passing. However, when we write recursive procedures, we have to use the stack.
I am very confused about the magic with working without the stack. Any standard program has a chain calls: Main()-> Function1() -> Function2() -> ... ->
Even with lots of registers (128) the way is usual:
Nobody stops us to use register-based parameter passing in CISC, especially on modern processors. So, how is it possible to do a program con RISC without the stack?
I think what they're referring to is argument passing. In most RISC machines, arguments are passed in registers and there are generally about 6-8 registers reserved for this purpose (and one for the return value). This isn't mandated, it's simply convention (and is called ABI or application binary interface). So, if there are fewer arguments to the function than registers and those arguments are simple enough to fit in a register, you don't need extra stack space to pass those arguments. On CISC machines, there aren't so many registers for arguments, so the ABI specifies that those arguments are passed on the stack.
Also, in RISC machines, there are many temporary registers available (specifically the callee save ones) for storing local variables. On CISC machines, local variables are generally allocated on the stack and registers are generally reserved for intermediate values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With