On Friday, Mar 12, 2004, at 13:34 US/Pacific, Koen van Leeuwen wrote: > 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 > (etc) This is pretty much a standard generic division algorithm, only doing the divisor shift manually, right? (and also terminating early since you know how many bits are in the divisor.) As such, it's nicely relevant to other division problems, but surely we ought to be able to do better since we know that we're dealing with SEVEN, after all? Does anyone have the relevant macro to produce the code above for any constant divisor? BillW -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads