Like Archangel mentioned above, you should also try the LOOKUP command. This command takes only a few cycles to execute.
Like Archangel mentioned above, you should also try the LOOKUP command. This command takes only a few cycles to execute.
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Henric, never the less, not as quick as 8 rotates and 8 jump on carry in-line. Worst case, with no bits set in the target thats only 16 cycles.
rscor01, I didn't realize LOOKUP would do that. How would that go?
George
Nevermind. You would need too many entries in the LOOKUP constant fields. That would be 64 entries to be precise since your variable PORT has 6 bits. It will be something like this
Still, it might be faster than NCD, but I don't know.Code:LOOKUP MyPort, [0,1,2,2,3,3,3,3,4,........], MyVar
"No one is completely worthless. They can always serve as a bad example."
Anonymous
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
I may be wrong but I don't think this will work.
LOOKDOWN2 Search,{Test}[Value{,Value...}],Var
Lookdown2 compares the value of "Search" with the values in the list from left to right (index values 0 up to 255) with the "Test" comparison.
So if "Search" = 5 and "Test" = "=>" then using your values for the Value in the list, the logic tests should look like this.
(Values: 0, 1, 2, 4, 8, 16, 32, 64, 128) bits 0-7
Test 1: is 5 => 0? : Yes, (0 will be stored in Var)
The testing would stop right here for every value of "Search" (0-255) for bytes (0-65535) for words because the "Search" value will always be greater than or equal 0 (unless you're using Long variables)
Maybe I'm wrong?
As I see it, to use Lookdown2 you would still need to enter all the values from 0 to 255 inclusive into the list.
And "Test" would need to be set to "="
Lookdown2 supports up to 85 values in the list or up to 256 when using a PIC18.
Last edited by Tabsoft; - 4th March 2015 at 02:03.
Regards,
TABSoft
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Thanks for the feedback.
I still think there are issues with this approach.
I ran a test and printed the output.
I ran a For/Next loop from 0 to 255.
e.g.
For i = 0 to 255
Lookdown2 i, <= [%00000000,%00000001,%00000010,%00000100,%00001000, %00010000,%00100000,%01000000,%10000000,%11111111], j
Next i
The output resulted in 247 wrong values out of 256.
I am attaching the output here.
Again, perhaps I'm wrong and missing something?
Lookdown2.pdf
Regards,
TABSoft
Bookmarks