movl $0x0(%esp) is a way to see the address of the stack pointer, as well as the values of the top and bottom registers.
movl 0x0esp will use the same stack pointer and return value as movl $0x0,%esp, but it will return a pointer that points to the next instruction after the “movl” instruction. This is handy for the same reason that movl $0x0,%esp, gets used for things like “addl”, which I think it is one of the easiest ways to get a pointer to an integer value.
This is a nifty way to write code that is a little bit faster than the simpler movl 0x0, esp, because we can move the stack pointer before the movl instruction and then just take advantage of that to avoid having to move the stack pointer in the movl instruction.
It is nice that movl gets us to the next instruction for us to use it, even if it’s only a single instruction, but we can do a lot more with that instruction as well. For example, we can move the stack pointer before we actually use the movl instruction, and then use that value as an offset rather than a pointer.
We can also move the stack pointer before we actually use the movl instruction, and use that value as an offset.
Of course, we can also avoid the movl instruction altogether by using a MOVW instruction with a single destination register.
That’s what we did in the example above, just using movw and a single destination register instead of the movl instruction. It’s not an instruction we don’t have access to, just not in a movl form.