0

at present i am studying MIPS architecture, in which i came across subroutine calls, it says that the stack allocation takes place within the processor using the registers

Source for this

But i have also studied basic programming course in java. And if what i know is correct! "stack memory allocation during function calls takes place in RAM "

this i confirmed from stack overflow (2nd ans)

Can anyone tell me where my understanding is wrong and if yes why?

thanks in advance

Community
  • 1
  • 1
vrogros
  • 25
  • 1
  • 8

2 Answers2

3

The stack is directly in the RAM and as for most processors, MIPS have registers to help it move efficiently into the stack and keep track of the data. The two important processor registers for that are the stack pointer (points to the top of the stack) and the frame pointer (points to the current stack frame in the stack).

ouah
  • 142,963
  • 15
  • 272
  • 331
  • So first a stack is created within the RAM and when subroutine is called by processor all data from stack created will again be transferred into the registers in register file in stack format is that it @ouah – vrogros Oct 30 '15 at 16:39
  • @selfish You don't create the stack, you just point your stack pointer somewhere and anything below it is the stack :) – biziclop Oct 30 '15 at 16:40
  • 2
    @selfish the stack is an area of the RAM (usually at the top addresses of the user virtual space memory), the stack registers are only used to move in the stack. – ouah Oct 30 '15 at 16:47
0

A stack is allocated out of RAM. Took a quick look at your link but couldn't find where they said stack allocation takes place within the processor using registers. Perhaps they were referring to where variables are placed prior to calling a subroutine.

JJF
  • 2,681
  • 2
  • 18
  • 31