I did a search here as I was looking for a way to use shifts and subtractions or reciprocal multiplication to divide a number by 12 for the modulus.

I have a formula for BCD that works for divide by 10.

There is only one place in the program where the mod 12 happens. Normally I would use the integer divide routines from the AVR tech notes.

Since this is only use in one place and the division is always by 12. The range of the dividend is at most 128 normally it will be 61 or 96. The quotient gets thrown away. (yes this is a music program.)

I did find some stuff her with a search on reciprocal multiplication as the target processor is a mega328 I have and use the mul instruction. I did try the 256/12 but there is not enough precision. Most examples are in C and deal with 32 bit integers. These examples are also for division rather than finding the modulus (I do not think that is called modulation though.)

Most of the examples go into theory. I am looking for more of a library template that I can drop in.

code size is not an issue but speed is.