I don't know how you could do this in Mach as any pin changes would create a reconfig estop. You could do it as Graham said with a relay or a dpdt switch. The normally open contacts would go to one of the axis step and direction and the normally closed would go to the other axis step and direction. The only problem with it is that Mach will not know whic axis it is driving or it's position. Some of the vb code gurus might be able to get very creative with some code for this, I'm not sure. The code would turn on or off an output that would change the state of the relay and zero the shared dro maybe. This would be a nightmare to generate Gcode for as well I would think. I think all things are possible tough. I'd like to see a drawing or pic of the machine it would be for and a description of what it will do.
Thinking out loud
Brett