Brooke, this is a routine I concocted for /14 with a remainder. You could modify it to /7. The application was a very big table in a 16F877 + external RAM. An inputted number referred to a bit within the table. For example 50,671 was the 50,671st bit from the bottom of the table. That bit then had to be retrieved by dividing by 14 (the byte width of 16F memory and also the RAM table), set from 1 to 0 and written back to the table ;========================================= ; Divide by subtraction, ;========================================= ;divide number (dendh:dendm:dendl) by 00000e (dsorh:dsorm:dsorl) ;result in resh:resl and rem ;resh:resl is address, remainder is bit position at that address div14 bcf res_eq0 ;clear result=0 flag movlw 0x0e ;low byte of divisor = 14 movwf dsorl clrf dsorm ;middle byte clrf dsorh ;high byte clrf dendh ;dividend high byte clrf resl ;result low clrf resh ;result high clrf rem ;remainder movf dendm,f ;quick test dividend for < 14 btfss zero goto dloop ;dendm > 00, continue division movlw 0x0e ;test low byte for < 14 subwf dendl,w btfsc status,c goto dloop ;dendl > 13, continue division movf dendl,w ;dendl between 1 and 13, exit movwf rem return ;exit with result=0 + remainder ;------- division loop for num > 13 dloop btfsc dendh,7 ;test for < 00 result goto end_div bcf status,c movf dsorl,w ;subtract divisor (14) from dividend subwf dendl,f movf dsorm,w ;ripple through higher bytes btfss status,c incfsz dsorm,w subwf dendm,f movf dsorh,w btfss status,c incfsz dsorh,w subwf dendh,f incfsz resl,f goto dloop incf resh,f goto dloop end_div decfsz resl,f ;return with address movlw 0x0e ;in resh : resl addwf dendl,w ;and bit position in remainder movwf rem btfss rem,7 goto test_0 movlw 0x0e ;add 14 -> correct any underflow addwf rem,f ;------- test result for 0 test_0 movf resl,w addwf resh,w ;add resl to resh btfsc zero ;if resl <> 00 return ;else exit with res_eq0 = 0 bsf res_eq0 return ;exit with res_eq0 = 1 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist