According to x86, ABI , EBX , ESI , EDI and EBP are savings account registers and EAX , ECX and EDX are call save registers.
This means that functions are free to use and destroy previous EAX , ECX and EDX values. For this reason, save the values ββof EAX , ECX , EDX before calling functions, if you do not want their values ββto change. This is what the call-save means.
Or better, use other registers for the values ββthat you will need after calling the function. push / pop EBX at the beginning / end of a function is much better than push / pop EDX inside a loop that calls a function call. Whenever possible, use blurred call registers for temporary ones that are not needed after the call. Values ββthat are already in memory, so they do not need to be written before re-reading, are also cheaper to spill.
Since EBX , ESI , EDI and EBP are saving registers, functions must return values ββfor the original for any of those that they change before returning.
ESP also saved, but you cannot mess it up unless you copy the return address somewhere. A failed / ret call is terrible for performance because modern processors use a return address predictor.
source share