The steps you describe is a normal homing cycle. I thought there was a homing function in Mach3 to do this. I don't remember what drives you are using, but some drives have a homing function built in.
Worse case, just write the script you described.