Completely unrelated to your problem, or perhaps not but anyway.....
Does these constructs really work? Do they even compile:
Code:
' FWD/RWD button
IF PORTC.1=%1 THEN
   IF rot=%0 AND run=%0 AND flag4=%0 THEN rot=%1:flag2=%0:flag4=%1
   IF rot=%1 AND run=%0 AND flag4=%0 THEN rot=%0:flag2=%0:flag4=%1
ENDIF

I think you need an ENDIF for each of those IF statements.