Because per the Microsoft X64 calling convention, RDI is one of the callee-save registers, a short description is here.noop wrote: Why do you push and pop the rdi register?
I don't know if for my code preserving RDI is actually necessary, but it might be and the conservative approach is to preserve it.