Unrolled, some things can be simpified so the whole thing is 31 instructions/cycles: ;division by 7 by Koen van Leeuwen ;number to be divided in divisor ;Trashed: w, divisor clrc clrf outcome ;start with clean reg movlw b'11100000' ;7 <<5 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of ;outcome is always zero btfsc outcome,0 ;If carry was 1, subtraction succeeded. movwf divisor ;so this should be our next divisor movlw b'01110000' ;7 <<4 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of ;outcome is always zero btfsc outcome,0 ;If carry was 1, subtraction succeeded. movwf divisor ;so this should be our next divisor movlw b'00111000' ;7 <<3 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of ;outcome is always zero btfsc outcome,0 ;If carry was 1, subtraction succeeded. movwf divisor ;so this should be our next divisor movlw b'00011100' ;7 <<2 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of ;outcome is always zero btfsc outcome,0 ;If carry was 1, subtraction succeeded. movwf divisor ;so this should be our next divisor movlw b'00001110' ;7 <<1 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of ;outcome is always zero btfsc outcome,0 ;If carry was 1, subtraction succeeded. movwf divisor ;so this should be our next divisor movlw b'00000111' ;7 subwf divisor,w ;check whether its too big rlf outcome,f ;shift in carry(/borrow) ;(=whether outcome is negative or not) ;and clear carry since leftmost bit of return ;and here is the result in outcome -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads