Is this guaranteed that CPU fetches memory in the opposite direction that stack grows?
0x00000000004004b7 <func+31>: mov -0x18(%rbp),%rax
For an architecture whose stack grows to lower address, the above fetches -0x18(%rbp)~-0x20(%rbp)
;And vice versa.
Is this true?
If that's the case,what'开发者_如何转开发s the technical reason?
In general, the CPU has no knowledge of how the stack is implemented (that's usually up to the compiler).
So in your case, it will fetch a word starting at address %rbp-0x18
. If a word is 4 bytes, then it will fetch the word that spans { %rbp-0x18
, %rbp-0x17
, %rbp-0x16
, %rbp-0x15
}.
No. The things two are unrelated. One is a property of the ISA, the other of the platform's ABI.
Incidentally, I do not know of any architecture on which multiple-byte accesses are not on ascending addresses.
精彩评论