4 ms·
You are correct, it has nothing to do with alignment. rbx is a callee-saved register, so the callee saves it.
by ridiculous_fish 6y ago
You are correct, it has nothing to do with alignment. rbx is a callee-saved register, so the callee saves it.
- deleted 6y ago[deleted]
- thayne 6y agoDo you mean thar rax is caller-saved?
- ridiculous_fish 6y agorax is indeed caller-saved, but I was referring to rbx. In this code: int bar(int a, int b) { int z = a * b; foo(); return z; } https://godbolt.org/z/a8Y35r https://godbolt.org/z/a8Y35r Where to put `z`? It has to be someplace where `foo` won't clobber it, like a callee-saved register - in this case ebx. But now `bar` is responsible for saving the value of ebx for its caller. That explains the push and pop. Alignment is unrelated; this is just about calling conventions.