An address which is a multiple of 2 is set to the stack pointer (SP).
The stack pointer always points to the lowest address of the stack frame. Therefore, values stored in areas with smaller addresses than the SP address are not guaranteed.
A stack area allocated by the caller function when the function is called is deallocated by the caller function on returning from the function call. Accordingly, the SP indicates the return address storage area at the entrance and exit of the callee function.
Below is shown the stack frame of functions f and g from the perspective of function f (Callee function), when function f is called by function g (Caller function).
Below is the area that function f can reference and set.
This is an area for setting parameters that are not allocated to registers. The data set in this area is aligned to the 2-byte boundary. When all parameters are allocated to registers, the size of this area becomes 0.
This is an area for allocating the return address. The size of this area is fixed to 4 bytes, and the address is set as a far address.
The value of the upper one byte of the 4 bytes is undefined.
This is a stack area used by function f to store local variables.
This is an area for setting arguments to be allocated to the stack when function f calls another function. If all arguments required for the function call are allocated to registers, the size of this area becomes 0.