The frame layout is particularly interesting. On the Intel x86 architecture in real mode we have the following:
Layout offset value +-----------------+ | arg3 | 6 +-----------------+ | arg2 | 4 +-----------------+ | arg1 | 2 +-----------------+ | return address | 0 +-----------------+ | frame pointer | -2 +-----------------+ | local1 | -4 +-----------------+ | local2 | -6 etc.
Note that variables that are stack arguments use offsets based on the state of stack _after_ the return address was pushed. The return address, if passed on the stack, is always considered to be at offset 0.
In addition, support has to be provided for architectures that have separate FPU stacks.