PDA

View Full Version : Array variable access time



achilles03
- 22nd April 2020, 20:47
I posted this question on another website but did not really get a straight answer.

If I have an array of 32 bytes defined in a variable SINB, and I execute the command "ampvar=SINB[lookbyte]", does the execution time vary as a function of index, or is the retrieval time constant? As a follow-up, are there any other suggestions that could speed up accessing an array or make it more consistent? (ex: storing in program code vs RAM).

I am aware that there are existing sin functions in PBP, but my end intent is to scale this up once I get it working.

Thanks in advance!
Dave

richard
- 23rd April 2020, 23:54
I posted this question on another website but did not really get a straight answer.


if my answer was not straight enough maybe your not asking the right question

achilles03
- 25th April 2020, 03:34
if my answer was not straight enough maybe your not asking the right question

Your answer specific to the "// 32" operation was extremely helpful and did indeed result in a significant speed increase. And I very much appreciate it. One of your later replies did address my first question (specifically "does an array lookup require more clock cycles than other instructions based on the array size?"), however it was after I had posted here (or perhaps I didn't see it until I had posted here). Either way, thanks again!

Dave

richard
- 25th April 2020, 07:48
thats not quite the question asked, it was


With respect to the 'ampvar=SINB[lookbyte]' instruction, does the execution time vary as a function of index, or is the retrieval time constant?

the only answer i could think of that made any sense was
(thinking is the timing different for an index of 0 verses 31 is inferred)


providing all the vars are byte sized the timing is constant regardless of index value

does the same hold true for word arrays, i don't know you would need to examine the .lst file to be sure.

its kind of a weird question anyway, given the largest possible pbp pic16fxxx byte array is 80 bytes, 40 for a word array. where are you going with this?

if you used an enhanced core p16f1xxxx chip much larger arrays of any type are possible using the memory in linear access mode , in asm of course.
you can even have huge arrays up to 14bits wide in flash accessable though the fsrx
indirect addressing process,[lightening quick] in asm of course.