0

I am a little bit confused with memory addresses.

I know that stack grows towards lower addresses and that .data section grows towards higher addresses.

Let's say I want to save 0x1234 in address 0x100.

  1. if 0x100 is in stack then 0x100 takes 34 and 0x101 takes 12

  2. if 0x100 is in .data then 0x100 takes 34 and 0x101 takes 12 too?

I'm sure about 1 but don't know anything regarding the case in 2.

Please Note: I am referring to little endianness.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
john
  • 3
  • 2
  • I wanted simple example with direct answer, I'm new and understand nothing from that question it had so many details. – john Oct 06 '21 at 21:13
  • 1
    The first line of the answer on the linked question is "Stack grown direction is orthogonal to integer endianness.". That's the answer to your question. A word store orders the bytes the same way regardless of whether you push or mov, or what region of memory you do it in. You could test that yourself on an ISA like x86, using a debugger to examine memory. – Peter Cordes Oct 06 '21 at 21:22
  • @PeterCordes I'm not native english and don't understand that sentence... can you answer 2 directly? – john Oct 07 '21 at 04:54
  • 1
    Yes, the layout is the same in both places. – Peter Cordes Oct 07 '21 at 04:59

0 Answers0