The jump from a BUTTON command is essentially a GOTO, not a GOSUB.
So from the "secondled" routine you should GOTO mainloop, not return.


And, assembly language interrupts can be used to immediately respond to events, even if a PAUSE 2000 is executing.