EBP and ESP are remnants of an era when compilers did not, for example, have static analysis to determine how many stack bytes are needed to call a function. In addition, the stack had to dynamically increase and decrease during the execution of the function, interrupts would clear the entire stack from 0 to SP, and the spaghetti code was the de facto standard. In fact, interrupts (and passing parameters only through registers) were a developed method for calling kernel functions.
Under these conditions, you need to have a fixed point on the stack where the return address is always found for the caller, local variables and function arguments. Thus, the bp register was justified. In this architecture, bp was allowed to be indexed ([bp - 300h]), but sp not. These opcodes / instructions, which could be interpreted as mov ax, [sp + 1111h] , were reused for other purposes.
In 386+ and thanks to the introduction of 'E', the ESP acquired a bias property. At this time, EBP was freed from its sole purpose, as esp was able to cope with both tasks.
Note that even now, EBP points to memory through the stack segment (SS), as does ESP . Other addressing modes (without ESP / EBP as the base) by default for the DS segment. (absolute, DI, SI and / or BX in 16-bit mode and in 32-bit addressing modes, any register can be a base in addressing mode).
source share