Is the top and bottom of the stack defined backwards here?
Posted: Tue Jul 27, 2021 9:00 pm
Reading this page:
https://wiki.osdev.org/Bare_Bones
I noticed this code snippet setting the stack pointer:
As this gets compiled and linked, `stack_bottom` will get a lower memory address than `stack_top`, i.e it will look like this:
The stack point will point to stack_top and grow toward stack_bottom.
But looking at memory layout of C programs, "bottom" should be at the high address and "top" at a lower address:
https://media.cheggcdn.com/media%2Fa00% ... plvboo.png
Shouldn't the labels be reversed in the assembly code?
https://wiki.osdev.org/Bare_Bones
I noticed this code snippet setting the stack pointer:
Code: Select all
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
...
...
Code: Select all
Low address High address
[.......... stack_bottom ............... <-- 16 KiB -- > ......... stack_top.........]
But looking at memory layout of C programs, "bottom" should be at the high address and "top" at a lower address:
https://media.cheggcdn.com/media%2Fa00% ... plvboo.png
Shouldn't the labels be reversed in the assembly code?