i'm not 100% sure of what you need but try this one..
Code:
TRISB=%00100000
emergency       VAR PORTB.5 'switch pin 
WichPORTB_Bit   var byte
Loop            var word
LedState        var bit

wichPORTB_Bit=4
ledstate=1

Start:
    For loop=0 to 500
        if emergency=1 then 
           PORTB.0(wichportb_bit)=0
           wichportb_bit=wichportb_bit ^7
           while emergency : wend
           pause 20
           endif
        PORTB.0(wichportb_bit)=ledstate
        pause 1
        next
    ledstate=ledstate^1
    goto start