Here's one very simple solution. Use Timer 0 as a background counter. This will count transitions of high-to-low, or low-to-high on RA4/T0CKI
Code:
DEFINE OSC 20
DEFINE LOADER_USED 1

P_Count var byte       ' Holds count value
TRISA.4 = 1            ' RA4/T0CKI = input
INTCON.7 = 0           ' Disable interrupts

' Set 1:1 prescaler & assign to WDT
' Set TMR0 clock to external input on RA4/T0CKI
' Increment on high-to-low transition on RA4/T0CKI pin
OPTION_REG = %00111000 

Main:
    P_Count = 0  ' Clear pulse counter
    TMR0 = 0     ' Clear TMR0 counter
    
Loops:
    P_Count = TMR0 ' Get TMR0 count
    HSEROUT ["Counts = ",dec P_Count,13,10]
    IF P_Count = 255 THEN Main  ' Clear when TMR0 reaches 255
    PAUSE 500
    GOTO Loops
If OPTION_REG.4 = 1 Increment on high-to-low transition on T0CKI pin.

If OPTION_REG.4 = 0 Increment on low-to-high transition on T0CKI pin.

Super easy, and all counting is done in the background while your program code plods along. Just check whenever it's convenient to find the count.