Creating Multiple Interrupts

What speed are steppers doing..
Will say a 20mS delay take them beyond the limit switch and cause damage..
IF not assume the software each 10mS repetitively executes a timer driven interrupt routine to read switchs.>
We use two reads to confirm the state switchs can bounce ... We set criteria of switch states into a look up table, so once you have a new configuration the look up in the table causes function call to next action

Simple example

3 inputs if I make up a sequence we could say
000
001
010
011
100
101
110
111
state 000 means start
001 never occurs
010 switch next stage
011 stop first etc..
now with the index into this table i.e entry 0,1,2,3,4,... we index into a function pointer table
this is defined as ..

typedef void(*func_ptr)();
func_ptr basic[15] = {finc1,func2,fun3,func4,...}

perfectly valid c

these array entrys are function names.. you may never have seen such an idea but its common to many industrial control sequence controllers. With the idea I can in fact have all standard operations in order or not in sequence in the array..

From the input pattern I can then algorithmically determine what sequence number to execute and call the function through the array.. using just a mathematically derived answer,

Perhaps this is too advanced for you but if your serious about cnc or any other sequence driven system you need these sort of ideas to handle all possible error combinations as well as vaid sequencing, believe me I have broken more process lnes than I care to remember simply because I was not aware of these ideas as a younger engineer..