Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who selects the ARM stack direction?

Tags:

stack

arm

As seen in this question the ARM stack grow direction is selectible, but who selects this direction exactly? The operating system? The app? The manufacturer?

If it is the operating system, what's the stack direction for iOS, Android and Windows RT?

like image 867
Denilson Amorim Avatar asked Sep 28 '13 18:09

Denilson Amorim


1 Answers

Ultimately it's the designers of the operating system who choose which direction the stack grows in.

If you want to create your own stack, and not rely on the one given to you by the OS, you can use whatever type of stack you choose. However, if you want to use the OS stack, you have no choice but to accept what the OS gives you.

The first OS that ran on ARM was Arthur, written by Acorn Computers. Arthur uses a growing-downwards stack, quite possibly because the developers who wrote Arthur were used to the stack on the 6502, which also grows downwards. (Arthur didn't last long, and was quickly replaced by RISC OS.)

There is a version of ARM Linux that runs on Acorn hardware - I still have a version of it on my 1995 Acorn Risc PC. I know that that version of the ARM Linux kernel makes calls into RISC OS for various purposes, so it has to use growing-downwards stacks as well. Other operating system developers quite probably followed the lead set by Acorn and/or the ARMLinux developers.

As for iOS, it appears to use a growing-downwards stack (the STMFD instructions here suggest that). I suspect the same is true for Android and Windows RT, but I haven't been able to verify this.

like image 104
Luke Woodward Avatar answered Oct 20 '22 20:10

Luke Woodward