Just a thought. I did something like this for a LDR to act as a motion detector. It should work for a switch.

checkswitch var bit
compare var bit
clear 'bits are 0
low portb.0 'output pin off

start:
let checkswitch = porta.0 'toggle switch
pause 50
let compare = porta.0
if compare <> checkswitch then toggle portb.0 : clear: goto start
goto start