stack-pointer

Why does %rbp point to nothing?

扶醉桌前 提交于 2019-12-10 12:16:36
问题 It is known that %rsp points to the top of the stack frame and %rbp points to the base of the stack frame. Then I can't understand why %rbp is 0x0 in this piece of code: (gdb) x/4xg $rsp 0x7fffffffe170: 0x00000000004000dc 0x0000000000000010 0x7fffffffe180: 0x0000000000000001 0x00007fffffffe487 (gdb) disas HelloWorldProc Dump of assembler code for function HelloWorldProc: => 0x00000000004000b0 <+0>: push %rbp 0x00000000004000b1 <+1>: mov %rsp,%rbp 0x00000000004000b4 <+4>: mov $0x1,%eax

Function call jumps to the wrong function

流过昼夜 提交于 2019-12-04 23:54:53
I am compiling a c++ static library in vs2008, and in the solution i also have a startup project that uses the lib, and that works fine. But when using the lib in another solution i get an run-time check failure. "The value of ESP was not properly saved across a functioncall" Stepping through the code i noticed a function foo() jumping to bar() instead right before the crash. The functions in question are just regular functions and no function pointers. Anyone has any clue what might be going on, and why it works when using the lib's from the same solution? edit: the functions (methods) are

x86 where stack pointer points?

霸气de小男生 提交于 2019-11-30 06:51:43
For example if I pushed ax is [SP] points to my value of ax or the word after ax? Also is it differs from real mode to protected mode? I ask this because the Art of assembly book illustrates and explains as the sp points to last pushed data, and on this page OSDev Wiki - Stack it illustrated as it points to empty word after last pushed data. Wikipedia says here : The stack is implemented with an implicitly decrementing (push) and incrementing (pop) stack pointer. In 16-bit mode, this implicit stack pointer is addressed as SS:[SP], in 32-bit mode it is SS:[ESP], and in 64-bit mode it is [RSP].

What is the purpose of the RBP register in x86_64 assembler?

旧巷老猫 提交于 2019-11-27 17:26:59
So I'm trying to learn a little bit of assembly, because I need it for Computer Architecture class. I wrote a few programs, like printing the Fibonacci sequence. I recognized that whenever I write a function I use those 3 lines (as I learned from comparing assembly code generated from gcc to its C equivalent): pushq %rbp movq %rsp, %rbp subq $16, %rsp I have 2 questions about it: First of all, why do I need to use %rbp ? Isn't it simpler to use %rsp , as its contents are moved to %rbp on the 2nd line? Why do I have to subtract anything from %rsp ? I mean it's not always 16 , when I was printf