logoalt Hacker News

josephg01/04/20262 repliesview on HN

Is there anything stopping us from doing this today on modern hardware? Why do we grow the stack down?


Replies

Veserv01/04/2026

x86-64 call instruction decrements the stack pointer to push the return address. x86-64 push instructions decrement the stack pointer. The push instructions are easy to work around because most compilers already just push the entire stack frame at once and then do offset accesses, but the call instruction would be kind of annoying.

ARM does not suffer from that problem due to the usage of link registers and generic pre/post-modify. RISC-V is probably also safe, but I have not looked specifically.

show 1 reply
sphlast Monday at 8:25 AM

Nothing stops you from having upward growing stacks in RISC-V, for example, as there are no dedicated stack instructions.

Instead of

  addi sp, sp, -16
  sd a0, 0(sp)
  sd a1, 8(sp)
Do:

  addi sp, sp, 16
  sd a0, -8(sp)
  sd a1, -16(sp)