Where did you get a 32 bit variable that PBP knows about? Is this a feature of PBP3?
Can you alias and access the same variable as the four bytes?
Since towerg mentioned “array” I’m not sure. a single variable of a datatype isn’t an array.
Where did you get a 32 bit variable that PBP knows about? Is this a feature of PBP3?
Can you alias and access the same variable as the four bytes?
Since towerg mentioned “array” I’m not sure. a single variable of a datatype isn’t an array.
You didn’t say what you want to do with the bit that drops off the end.
Assuming you want what PBP shift would do with a byte, and just drop the end bit,
and feed in a zero to the right.
So long as you can access the first byte by aliasing it, I’m sure the assembler is a continuous 4 bytes.Code:dis var byte [4] BitwiseRotateLeft: ' bitwise rotate array @ rlf _dis+3 ,F ; ditching the first bit @ rlf _dis+2 ,F ; @ rlf _dis+1 ,F ; @ rlf _dis+0 ,F ; @ bcf _dis+3 ,0 ;clear MSB return
Well, yes, it is a PBP3 feature. But besides that, even if you are on a previous version, you may still face the fact of 32 bit variables.
At the cost of 4x8x32 bytes, George's approach is obviously the fastest because n (times a shiftmust happen) can be anywhere between 1 and 32.
Thanks for the post.
Ioannis
Oh I get it, the 32 bit var always has 31 clear bits and 1 set bit.
Yes, thats right.
In case you wonder is part of the Microchip Keeloq algo. A really intense algo...
Ioannis
Can LOOKUP/2 now contain enough elements,
or you'd need to use 4 lookups? (One for each byte element of the 32 bit val).
It does sound like reading program memory would be economical for that.
Last edited by Art; - 24th November 2015 at 17:47.
Since using LONGs in the program will slow down the execution of the program, I am reluctant to use longs. Also the PIC that curretly is used is 16F series.
So, seems better to spend some bytes in RAM or FLASH and have immediate response.
Ioannis
Bookmarks