#### Mike - K8LH

##### Well-Known Member

How do I implement the following formula, which has an intermediate result that is wider than 32 bits, using integer math in C? I know how to do it in assembler but I've been forced to use the 64-bit MPLABX v5.40 and XC8 v2.31 in order to use the new 18F16Q40 chip and XC8 no longer supports in-line assembly code...

TIA... Cheerful regards, Mike

Code:

```
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Fosc 32000000-Hz (8000000-Hz 4xPLL) - convert decimal 8-digit ~
; input (range 100000..15999900) into a 20-bit 'NCO1INC' value. ~
; ~
; nco1inc = bin = INT((frequency/100)*65536/10000+0.5) ~
; ~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```