Here's the initial approach, I've modified for my needs. It does not works, what may be the reason?

Code:
LEFT var GPIO.0
RIGHT var GPIO.1
COUNTER VAR word
counter=128

cycl:
if LEFT=0 then                 'here is switch 1 of the rotary encoder
    counter=counter+1
    goto lcd
endif
 
if RIGHT=0 then                 'here is switch 2 of the rotary encoder
    counter=counter-1
    goto lcd
endif
 
goto cycl
 
lcd:
hpwm 1,counter,5000
while (LEFT=0 or RIGHT=0):pause 10:wend
goto cycl
MCU is PIC12F683