I want to use 'rbx' and 'rcx' registers in my function and before using them, I want to save them. Since it's 2 registers, I want to know which way is better? push them one-by-one or reserve stack (16-byte) and copy each value into the stack and ...
Way1:
FUNC:
push rbx
push rcx
...
...
pop rbx
pop rcx
Way2:
sub rsp, 16
mov QWORD [rsp], rbx
mov QWORD [rsp+8], rcx
...
...
mov rbx, QWORD [rsp]
mov rcx, QWORD [rsp+8]
add rsp, 16
The second way has more source code (size), but I'm talking about CYCLE. When I just want to use a register, it's clear that I must use push but what should I do for 2 or more registers like this? Push them one-by-one or stack reserve and ...?
I heard that push is: 1 - reserve stack 2 - copy the register value into the reserved stack
and also pop is: 1 - copy the value into the register 2 - restore stack
So for 2 or more registers, I can do it my self without multi reserve and restore (stack)