No global variables.
Global variables are much simpler to implement since they share the same namespace as functions, and always have a fixed address.
We could store the variable’s offset from ESP, except that the value of ESP changes whenever we push something onto the stack. The solution is to store the variable’s offset from a different register, EBP.
You can also keep track of the stack offset, since you're generating the code and know what's been pushed/popped. Using ESP-relative accesses makes the code slightly larger (due to SIB byte) but is often used since it frees up EBP for more useful things. Of course this is a somewhat moot point if you're not going to use it anyway, but speaking as someone who has read a lot of compiler output over the years, ESP-relative accesses seem to be somewhat more common in released code.
This is the fifth post in a series. Read part 1 here.
It would be better to also link to the previous part, for those who just want to read what came immediately before and not start again from the beginning.
[1] https://www.engr.mun.ca/~theo/Misc/exp_parsing.htm#climbing