PASM math...

I know there is a post on the wiki, but I don't think I understand it very well yet.
What I need to do is calculate a delay value based on the system clock, or compute timing constants at key times, something like:
i := (CLKFREQ / 10) * duration + CNT
(however fast --don't care)
x = x / y
and x = x * y.
Both with 32 bit results and operands. These are for general case setup / init tasks, mostly to enable PASM to be built up binary blob style. I realize the multiply will overflow, but I don't think it's a problem at this point. For most all the cases I'm thinking of, one operand will be considerably smaller than 32 bits.
What I need to do is calculate a delay value based on the system clock, or compute timing constants at key times, something like:
i := (CLKFREQ / 10) * duration + CNT
(however fast --don't care)
x = x / y
and x = x * y.
Both with 32 bit results and operands. These are for general case setup / init tasks, mostly to enable PASM to be built up binary blob style. I realize the multiply will overflow, but I don't think it's a problem at this point. For most all the cases I'm thinking of, one operand will be considerably smaller than 32 bits.
Comments
don't post, until I crash on that. Thanks!!
http://mathforum.org/library/drmath/view/54375.html
This kind of thing makes me very happy
I think I've got the math right, but now need to code up some test cases to vet it. Division is a PITA, when range is a consideration...
You know... standing on the giant's shoulders...
Massimo
Well, I started with the simple multiply and divide routines found in the Prop Tool and Wiki. Chips math module in the Pnut interpreter is another potential target.
Most all of what I've done uses simple math, or a lookup, or some specific multiply / divide case. Those things can be done with shifts, rotates, adds, and the occasional clever trick, and are something one works out for that task.
So it's a weak spot, and something I've wanted to get a better handle on. With math, I find it best to do it on paper, then start working through the process on a computer.
There is the performing of the computation, then there is actually understanding how to use the result obtained, and finally scale vs number of bits vs precision. It's hard to get a good feel for whether or not those things are properly balanced for the task at hand.
Edit: This is the document I was thinking of --> www.jacques-laporte.org/Meggitt_62.pdf
Division: http://forums.parallax.com/showthread.php?t=114807
Multiplication: http://forums.parallax.com/showthread.php?t=114911