开发者

Is this guaranteed that CPU fetches memory in the opposite direction that stack grows?

开发者 https://www.devze.com 2023-03-21 15:42 出处:网络
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.
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消