Code:
ampm var portb.7
trisb=%11111110
Making "ampm" an input.

But then you are writing to "ampm" as an output.
Code:
ampm=1