I am learning x86 assembly. I am trying to understand how "exiting program" works on x86. We have a code :
push ebp
mov ebp,esp
//Some stuff here
mov esp, ebp
pop ebp
ret
When processor executes instruction "ret" :
EIP will have value, which is popped from stack, in other words 0.
so processor will go to 0 address and will try to execute instructions ... which doesn't contain program code/executable code.
So, what is really going on with processor? Are there condition check, for example, if EIP = 0 -> exit program?
Or if ESP out of bounds -> exit program?
`How processor understands that this RET instruction is the end of the program?