What are the different registers used by the C++ compiler in a program? What is the difference between SP and FP? If possible please point me to some detailed reference docs. Curious to know the underlying things happening in a compiler. Is it possible to view these registers during the execution of a program in Visual Studio. Appreciate your time and help. Thanks in advance, Light
The answer to your question depends on the hardware you are programming to. Each processor family has it's own architecture and therefore it's own register.
Here is a good reference on Wikipedia for the Intel chips.
You can ask compiler to output the assembler code it generates from your sources, it's /FA and /Fa compiler command line arguments you're looking for: msdn link to /FA compiler arg.
In run-time, when you're running your program under debugger, you can open a "registers" window, and see how the values change during the execution - it can be very useful sometimes. Here's how you do it: msdn doc about "registers" window
If you're going for more serious debugging, I'd recommend investing some time learning to use this: debugging tools for windows instead of just using the built-in VS debugger.
A stack pointer (SP) points into memory and is used to store function call-related data such as function parameters, return address and local variables. This data forms a stack frame for each function call and is pointed at by frame pointer (FP). Each thread of execution has a stack pointer. Each function call has its own stack frame and frame pointer. A stack backtrace works its way back through the stack frames of each nested function call allowing you to see the parameters and local data of each function call.
http://en.wikipedia.org/wiki/Frame%5Fpointer#Structure
The above link contains more description and a picture.