Take your pic, I mean pick. Here's a routine that's designed to simultaneously debounce 8 inputs. I've used it in conjunction with a keyboard scanning routine and also as a generic parallel digital input port. It's currently set up such that four consecutive samples at the same logic level are required for the filter outputs to change states. BTW, there are no gotos and no counters.
Vertical counters provide an efficient way to simultaneously count up to eight different items.
Like most of the John writes, this is bizarre, interesting, and extremely fast. The 32-level pwm routine is really intended for fixed pwm duty cycles. This is mainly because it's not possible to maintain single cycle resolution and simultaneously smoothly vary the duty cycle. Well, okay, maybe it's possible. However this routine also provides the application with about 15 free instruction cycles per pwm cycle.