Hi, I am trying to convert Eric Smith's sine function ( http://www.brouhaha.com/~eric/pic/sine.html ) on a 16f84. I have included the code below. It does not seem to work. When I step through the code in MPLABS SINETBL is called, but returns after the ADDWF. Then the code reaches the final RETLW and goes back to CALL SINETBL, but does not call it, and ends up in a loop. Any help appreciated. temp EQU 0xC zero EQU 0xd ; Set up: PORTA = Input PORTB = Output ; The bitstring to be checked will be entered in PORTA BSF STATUS, RP0 ; Select bank 1 MOVLW B'11111111' ; 1 to set input MOVWF PORTA ; Set PORTA as Input MOVLW B'00000000' ; 0 to set output MOVWF PORTB ; Set PORTB as Output BCF STATUS, RP0 ; Select bank 0 ;*********************************************************** GOTO START ;*********************************************************** ; SUBROUTINE SECTION SINETBL ADDWF PCL, F ; or PCL? dt 000h,003h,006h,009h,00ch,010h,013h,016h dt 019h,01ch,01fh,022h,025h,028h,02bh,02eh dt 031h,033h,036h,039h,03ch,03fh,041h,044h dt 047h,049h,04ch,04eh,051h,053h,055h,058h dt 05ah,05ch,05eh,060h,062h,064h,066h,068h dt 06ah,06bh,06dh,06fh,070h,071h,073h,074h dt 075h,076h,078h,079h,07ah,07ah,07bh,07ch dt 07dh,07dh,07eh,07eh,07eh,07fh,07fh,07fh dt 07fh ;*********************************************************** ; MAIN PROGRAM START MOVF PORTA, 1 ; Read the contents of PORTA into itself MOVF PORTA, W ; Move contents of PORTA into W MOVWF temp BTFSC temp,6 SUBWF zero, W ANDLW 07fh CALL SINETBL BTFSC temp, 7 SUBWF zero, w MOVWF temp ; Move result to temp MOVF PORTB, w ; Move result from temp to PORTB RETLW 0 END ; End program Regards, Evan ----- End forwarded message ----- -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist