-> But, what about the case where chars, short ints, were scattered in between 4 and 8 byte members?
char equ db
mystruct struct
one char ? ;1
two ptr ? ;8
mystruct ends
mystruct struct
one char ? ;1 ;8-1=7, next member fits in 7 bytes (is dd,dw,db)?
;no, so pad that
pad db 7 dup (?) ;8
two ptr ? ;16
mystruct ends
-> Now the programmer would have to insert padding to make the struct work out to something divisible by 8?
If you do that by hands, answer is yes. And this gets more crazy when exist structures inside structures.
When our program starts, stack pointer ends with 8, or, rsp == ???????8h. To do any call to a function, rsp should be rsp=???????0h (16 bytes aligned means that a number ends with 0 in hexadecimal).
The only exception happens with leaf functions. Functions that do not call other functions internally is one example of leaf function. In this case we can call that function with rsp ending with 8 or 0 in hexadecimal. But, to be sure, it's better call that with rsp ending with 0h.