Did you look at:
http://www.piclist.com/techref/piclist/codegen/constdivmul.htmIt works quite well.
Regards,
Gordon Williams
----- Original Message -----
From: "Ed Sutton" <
esutton@...>
To: <
piclist@...>
Sent: Thursday, May 08, 2008 11:59 AM
Subject: [PIC] - Need fast divide by 14 constant routine? ( Random
access8-bit data in PIC16F flash )
: Are there other ways to implement a divide by a 14 constant other than
: cycle-chewing subtraction loops?
:
: I want to use the PIC16F flash consisting of 14-bit words to store 8-bit
: data. I can implement the multiply-by-8 as a shift. The crux of the
: problem is basically the divide by a constant of 14.
:
: Pseudo Code ( actual code will likely be assembly )
:
: wordOffset = 8*byteOffset / 14; // The integer result
: wordBitOffset = 8*byteOffset % 14; // The remainder result
:
:
: Patterns:
:
: The 14-bit words and 8-bit data have a common multiple of 56.
: The wordBitOffset pattern { 0,8,2,10,4,12,6 } repeats every 7-bytes.
: I can't see a solution but it is an interesting puzzle.
:
: Thanks in advance for any tips or suggestions,
:
: -Ed
:
: --
:
http://www.piclist.com PIC/SX FAQ & list archive
: View/change your membership options at
:
http://mailman.mit.edu/mailman/listinfo/piclist:
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist