AnsweredAssumed Answered

Strange behaviour modulo operation

Question asked by ChristianH on Nov 4, 2013
Latest reply on Nov 5, 2013 by ChristianH



I'm a little confused about modulo operation but maybe there is a stupid simple answer that I don't see at the moment.

I use a ADSP-21469 programmed with VisualDSP++ 5.0 Update 10.1 in "C".

I tried to do a modulo operation but failed with a result of 0 all the time.


Following I've tested:

#define NUM_SAMPLES 0x10000

tempsize = TOC.Data[n].length % NUM_SAMPLES; ==> result is always 0


[08E4FE] r2=fext r2 by 0:0x6;

[08E4FF] r2=lshift r2 by 0xa;


but if I replace the NUM_SAMPLES by it's value:

tempsize = TOC.Data[n].length % 0x10000; ==> correct result


[08E4FE] r2=fext r2 by 0:0x10;


In my opinion the first code can not work correctly.


At another code location I've also used a modulo operation and the result was

[08D6A7] cjump ___uldiv(db)

giving me also the correct result (modulo value is 0x5A).


Any ideas?