pub struct CIpv6Address {
pub address: [u16; 8],
}
pub fn h() {
let x = CIpv6Address {
address: [1,2,3,4,5,6,7,8]
};
}
generates
sub rsp, 32
mov word ptr [rsp + 16], 1
mov word ptr [rsp + 18], 2
mov word ptr [rsp + 20], 3
mov word ptr [rsp + 22], 4
mov word ptr [rsp + 24], 5
mov word ptr [rsp + 26], 6
mov word ptr [rsp + 28], 7
mov word ptr [rsp + 30], 8
mov rax, qword ptr [rsp + 16]
mov qword ptr [rsp], rax
mov rax, qword ptr [rsp + 24]
mov qword ptr [rsp + 8], rax
add rsp, 32
ret
as can be seen here: https://godbolt.org/z/P4UHa_
I understood that it makes room in the stack pointer and fills with values. Why it starts at rsp + 16 though?
I can see then that if fills jumping by 4 bits. Why? My values are of 16 bits.
Finally, why it transfers the values from rsp +16
and rsp+24
to both rsp
and rsp+8
?