This has been on my todo list for some time.
Sometimes we need more "bits" than the 16 in the standard picaxe word. One of the chips that has been frequently discussed is the AD9850 which needs the calculation
val = (n * 2^32)/125,000,000 solving, where n is the desired output frequency, to program the frequency on the chip.
So today I bit the bullet and have produced a series of routines that can do arbitrary precision arithmetic with routines for add, subtract, multiply, divide, increment, decrement, shift left and shift right.
In the code below this is set to 64 bits. It can be any multiple of 8 below this settable with a single symbol 'precision' and with a minor modification to the storage registers (these currently use ram locations 56 to 79) can be more.
The code has been optimised to some extent and tested on the simulator against excel and the AD9850 design calculator.
Please test and provide any suggestions for further optimisation. I'll post to the code snippets once this is finalised.
The use of the code modules should be self-explanatory but I'll try and answer any questions.
The code has been ported from the assembler given by http://avtanski.net/projects/math/
SEE NEXT POST FOR REVISED CODE
Hope this is helpful
Peter
Sometimes we need more "bits" than the 16 in the standard picaxe word. One of the chips that has been frequently discussed is the AD9850 which needs the calculation
val = (n * 2^32)/125,000,000 solving, where n is the desired output frequency, to program the frequency on the chip.
So today I bit the bullet and have produced a series of routines that can do arbitrary precision arithmetic with routines for add, subtract, multiply, divide, increment, decrement, shift left and shift right.
In the code below this is set to 64 bits. It can be any multiple of 8 below this settable with a single symbol 'precision' and with a minor modification to the storage registers (these currently use ram locations 56 to 79) can be more.
The code has been optimised to some extent and tested on the simulator against excel and the AD9850 design calculator.
Please test and provide any suggestions for further optimisation. I'll post to the code snippets once this is finalised.
The use of the code modules should be self-explanatory but I'll try and answer any questions.
The code has been ported from the assembler given by http://avtanski.net/projects/math/
SEE NEXT POST FOR REVISED CODE
Hope this is helpful
Peter
Last edited: