According to Intel in x64 the following registers are called general purpose registers (RAX, RBX, RCX, RDX, RBP, RSI, RDI, RSP and R8-R15) https://software.intel.com/en-us/articles/introduction-to-x64-assembly.
In the following article, it's written that RBP and RSP are special purpose registers (RBP point to the base of the current stack frame and RSP point to the top of the current stack frame).
https://www.recurse.com/blog/7-understanding-c-by-learning-assembly
Now I have two contradictory statements. The Intel statement should be the trusted one, but what is correct and why is RBP and RSP called general purpose at all ?
Thanks for any help.
Answer
General purpose means all of these registers might be used with any instructions doing computation with general purpose registers while, for example, you cannot do whatever you want with the instruction pointer (RIP) or the flags register (RFLAGS).
Some of these registers were envisioned to be used for specific use, and commonly are. The most critical ones are the RSP and RBP.
Should you need to use them for your own purpose, you should save their contents before storing something else inside, and restore them to their original value when done.
No comments:
Post a Comment