# Code Generation for Constant Multiplication/Division

By Nikolai Golovchenko. See https://www.golovchenko.org/home/constdivmul for a working online form and source code.

 Input/Output register name: Input register size, bits Bytes order : big endian little endian This application is mirrored at: Multiply by constant: Tip: To divide by a number, enter the value of 1/number into the field. Maximum error in constant approximation, %  Round result Temporary register name: Select processor: PIC SX

See:

Questions:

• STOPspamdanmiller0SPAM at yahoo.com asks:
IS there a way of getting this code generation program in a simple windows program? It would be handy for when I am working from a workstation that does not have internet access.

The program does have a command line mode (not GUI) so it could be used locally... If there is enough interest, I could sell offline versions. Perhaps this would help to support the site? +

• STOPspamjdSPAM at xtremepowersystems.net " I would definitely buy a version that supported the PIC18 parts, so that the MULWF instruction was used whenever possible!
" +
• STOPspamebp1SPAM at telus.net
When used for division, except in cases where the sum of the terms exactly equals the divisor (e.g. divisor is 8/3 = 2.6666667), the computed quotient will always be slightly smaller than the actual quotient. Rounding can be helpful, particularly with small quotients. Before the final shift, simply examine the highest-order bit that would be shifted out and add it after the final shift.
e.g. if the last shifting is 4 places and the bits that would be shifted out are 1xxx, add 1 after the last shift.
Try this for 9 divided by 3, using 7 terms. Without rounding, the quotient will be 2. Rounding "fixes" that.
+
• STOPspampicSPAM at harry-arends.nl " When i use the code to make a routine that does arg*10 is works wel but when i want to make a divider using 1/10 is produces some useless code." James Newton replies: Please do not enter "1/10". Instead enter the RESULT of 1/10 which is ".1". Given .1, it generates very nice code for dividing by 10.+

+

Interested:

 file: /Techref/piclist/codegen/constdivmul.htm, 5KB, , updated: 2022/2/16 12:24, local time: 2024/6/19 18:44, TOP NEW HELP FIND:  3.236.142.143:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?Please DO link to this page! Digg it! / MAKE! Code Generation for Constant Multiplication/Division

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here:
if you want a response, please enter your email address:
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

.