Hi! 26-Mar-98 15:42 Scott Dattalo wrote about "Re: Divide by 3 (by 5, by 10)": >> Vladimir M. Klochko wrote: >> > ; Divide by 10 >> >> > ;; 23 words and 1 byte ^^^^^^^ >> Here's an 18 cycle Divide by 5: >> ADDLW 1 >> SKPNC >> RETLW 0x33 >> >> MOVWF ql .... >> ADDWF qh,W I didn't analyse this code. It seems good. But... First of all, "18 cycles" is not quite true. :) Since You use RETLW for some special case of input You must add a RETURN to this code for any other cases. Of course, my examples don't contain these RETURN's at all, but I don't imply a subroutine. I prefer (when it's possible) to make some macros for later usage. When I need a subroutine I can compose it using such macro and return instruction. When I need it only once in some program I can simple use the same macro in the program (without "return"). Another disadvantage is the TWO temporary bytes of RAM have to be dedicated for this code (my examples use only ONE byte). It doesn't cause a problem itself, but sometimes it is too difficult to maintain the temporary memory space usage. In reality it is a "compiled stack" (the same as the one provided by advanced C compilers). To keep in mind the whole call-tree (and manually rebuild it after any sorce change) is not an easy task for human. So, "the less temporary memory space the better". :) Sometimes I prefer even the slightly larger code (to make an wide-used macros) if it requires the less RAM space or no RAM at all. Of course, everybody has its own approach. >> >> Scott >> >> --- >> If you believe everything you read then you shouldn't read. >> Japanese Proverb Well. Am I ready to read? Am I ready to read Japanese? :) -- Vladimir M. Klochko