Hi, I've written set of c-callable assembler functions. The purpose was to make some fractional arithmetic faster, however now it's mostly curiosity why it's not working. I have functions for adding, subtracting, multiplying etc. All of them look quite similar: set status registers ,copy 1st arg from T0 to AC0, make certain arithmetic and store result in AC0, shift AC0 (Q15), store return result in T0,restore status register to their previous state. ADD and SUB are working fine, but when using MPY instruction result in AC0 is always zero, for any arguments. I'm not talking about return value, I've checked in debuger, that right after MPY instruction AC0 is zero. I have even tried to make multiplying by constant (MPYK #2,AC0), and it's still zero. Source code is below. Status register initialization is same as in DSPLIB mul32 function, but other combinations was also tested. Hope that someone have some assembler experience and can tell what is going on.
Thanks in advance
C:
extern Int16 fmul(Int16,Int16); |
ASM:
.def _fmul PSH mmap(ST2_55) PSH mmap(ST1_55) PSH mmap(ST0_55) POP mmap(ST1_55) POP mmap(ST2_55) POP mmap(ST3_55) |