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
Yes, you are right. We should always use truth tables just to make sure it is correct. We were just giving Matias a general idea. Try this now,
Code:For i = 0 to 255 Lookdown2 i, <= [%00000000,%00000001,%00000011,%00000111,%00001111, %00011111,%00111111,%01111111,%11111111], j Next i
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Thanks. That works great.
To find the port pin state using this, you would just need to decrement the return value by 1 if the value is >0 ( same for NCD).
When I get some time I will run this against NCD and check the instruction cycles to see which is quicker.
Thanks again.
Regards,
TABSoft
Bookmarks