Hi BasePointer,
I am not sure what you mean by limitations, or what type of problems you had with the PIC, but I can discuss some fundamental problems with sharing a subroutine between an ISR and non-ISR code. This applies to almost all processors and all programming languages, not just PIC or HC08, and not just C or assembly language.
The problem, in its most basic form, comes from the asynchronous nature of the ISR: The main program may be in the subroutine when the interrupt occurs and calls the subroutine again. If the subroutine uses any single-instance variables (static or global variables in C), then the second invocation (from the ISR) could overwrite the value needed by the first invocation. If the subroutine uses multi-instance variables (local variables in C) than each call to the subroutine will create unique copies of the variable on the stack, and the individual function calls would not interfere with each other. Such a function is reffered to as "re-entrant". In C, it is easy to write re-entrant functions, and your function "ProcessBitFilter()" does indeed look re-entrant.
What your code does not make clear is whether the same piece of
data might be referenced from both the ISR and the main code. If so, than you have a situation known as a "critical section". If the interrupt occurs when ProcessBitFilter() is operating on the structure passed to it, and the ISR then tries to manipulate the same structure, together they will likely corrupt the data in the structure. This can be avoided by insuring that interrupts are disabled during any access to the shared structure.
But that is not so obvious to implement in C code. By default, the main routine will call ProcessBitFilter() with interrupts enabled, and the ISR will call ProcessBitFilter() with interrupts disabled. It would be safe to enable interrupts as the first line of ProcessBitFilter(), but NOT safe to re-enable them at the end of ProcessBitFilter(). The best way to implement the critical section is to save the state of the interrupt mask first and then disable interrupts. Later, when access to the critical section data is complete, the saved state of the interrupt mask can be restored. The assembly code would look like this:
;; Save the interupt state:; tpa ; copy the Condition-code register to the accumulator psha ; save the copy on the stack sei ; disable interrupts temporarily;; Put critical section code here.;;; Restore the interrupt state:; pula ; get saved condition-codes from the stack tap ; restore interupt mask, as well as all other condition codes.