Hardware multiplier access in SPIN2 language
rogloh
Posts: 5,786
in Propeller 2
Is there a way to make use of the P2 hardware's MUL or MULS instructions in SPIN2 or does it always have to use the CORDIC engine for this?
I've found cases where I know the items being multiplied are both 16 bit quantities and it would be nice to be able to get a fast 2 cycle multiply done instead of the slower / general purpose CORDIC operation. How is this achievable? If it currently is not part of the language could it be extended to support it or is that too hard to fit in these days?
If it needs to be coded in inline PASM is there so much overhead to setting up the inline PASM vs using the CORDIC that it wouldn't be worth it?
Comments
Yes, I saw what the compiler (Flexspin) did with my functions. They may be 20xfaster. The temporary solutions may be
Flexspin indeed uses MUL for 16 bit values.
compiles to
and
compiles to
Sadly it doesn't seem to have the ability to squeeze other instructions inbetween the QMUL and GETQX.
Good to remember that Spin2 allows declaring the local variable type I will replace all longs where they are not needed.
I would need to make the interpreter look at the input data sizes and dynamically do MUL or QMUL.