start:
Low portb
cl = portb >>5 ' now we keep only Bit 5,6,7
SELECT CASE cl
CASE %011,%001 : goto Left ' if cl.5 = 1 and cl.7 = 0 and cl.6=1 then left
' if cl.5 = 1 and cl.7 = 0 and cl.6=0 then left
CASE %010 : goto Straight ' if cl.6 = 1 and cl.5 = 0 and cl.7=0 then straight
CASE %100,%110 : Goto Right ' if cl.5 = 0 and cl.7 = 1 and cl.6=0 then right
' if cl.5 = 0 and cl.7 = 1 and cl.6=1 then right
CASE %000 : Goto Stationary ' if cl.5 = 0 and cl.6 = 0 and cl.7=0 then stationary
END SELECT
GOTO Start