How to use software based endstops?

The are a couple of other threads discussing hardware end indicators or position indicators.
Home / Limit switch - Contributions - OpenFlexure Forum
and
An absolute position encoder for the Openflexure Microscope - Contributions - OpenFlexure Forum
Other than that it is hard to have a reliable software end-stop. The current position in motor steps is supposed to be non-volatile, but it is susceptible to being wrong from missed steps or software reset.