Originally Posted by Bubba
Which is why I don't like MASM. It's too political, I'd rather use NASM where nothing is assumed.
Yes, there is a way to tell MSVC to keep it's grubby hands off of your assembly code - but you cannot guarantee that you are optimized to the max while doing it. For instance if MSVC was using a register prior to your code and then you use the same register....you have a problem.
Here is how the compiler deals with it. Since you have no idea what registers the code is actually using because, for the most part, all you see is C/C++ code. So when the compiler sees that you want to use a register that it is already using, it pushes the value of that register onto the stack. When you are done with it, or when it deems you are done with it, it pops it off the stack and resumes what it was doing.
In DJGPP and AT&T syntax there is a way to specify which registers get 'fragged' so the compiler can better use registers prior to and after your code.
But with modern processor speeds, I doubt register problems will amount to much.
And I might add that Fordy pointed something very important out to me not long ago about inline assembly. If you are going to need to access the stack, do it from your assembly code. Don't attempt to use temporaries and then load those in your code. It looks nicer, but it is significantly slower. I'm sure with some searching you could probably find this thread on the board in a search for 'Bilinear interpolation.'