How to make the code run only on interrupt?
Right. The interrupt pins are active low. So whenever the P3.2 pin (~INT0) is low, there will be an interrupt. You have assumed the opposite and are trying to measure an active high input signal. Your options are:


invert the signal 
convert to falling edge triggered (which will give you the correct count although on the wrong edge, which for wind speed measurement is OK)


If you set "TCON" register bit 0 ("IT0") it should trigger on the falling edge. See page 29. That also says:


  (Bit 1) Interrupt 0 Edge flag. Set by hardware when external interrupt 0
  edge/low level is detected. Cleared by hardware when the interrupt
  is processed, or by software.


which sounds like you don't need to actively clear interrupts, so Dave Tweed's answer may not apply.