I'll propose something, but I won't actually read your code. It's far too ugly. Separate code items such as subroutines don't stand out enough to see them without a lot of searching. You also didn't place it in code tags to preserve any formatting you might have had. See the "Before you make a query" thread.

If a subroutine call is actually going to the subroutine, but not returning to the point of the call, then you have no doubt corrupted the return address. For most microprocessors, that would be because you've clobbered it on the stack.