One of the several way to do it, untested though
Code:
Frequency var word
CounterA    var Byte

If PORTB.5 = 0 Then
        CounterA = 0
Yelp:        
        Lookup2 CounterA,[366,483,591,664,760,886,967,1070,1182,1330,1182,1070,967,886,_
                        760,664,591,483,366],Frequency    
        Freqout PORTB.0,10,Frequency
        if PORTB.5=0 then
            CounterA = CounterA + 1
            if Countera < 19 then goto Yelp
            endif
        endif