PASM version of LOOKDOWNZ?
JonnyMac
Posts: 9,108
In Spin I would do this:
This is what I'm doing in PASM -- is there a better (more effective/efficient) way?
setup := lookdownz(ch: %1100, %1110, %1101, %1111)
This is what I'm doing in PASM -- is there a better (more effective/efficient) way?
chloop and ch, #%11 ' keep 0..3 cmp ch, #0 wz if_e mov setup, #%1100 if_e jmp #muxbits cmp ch, #1 wz if_e mov setup, #%1110 if_e jmp #muxbits cmp ch, #2 wz if_e mov setup, #%1101 if_e jmp #muxbits mov setup, #%1111 muxbits
Comments
edited: sorry, left out the main jmp
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
The trick works great with the mux bits for the ADC0834, but not with the ADC0838 (as I can see now). I looked at the way SX/B compiles LOOKDOWN and came up with this PASM equivalent for the ADC0838; seems to work but is brute force. Is there a better way? Speed is not an issue at all.
I _think_ that should work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
As long as the bits just need order swapping then either lonesock's method or the method below will work... either way it comes out to the same number of instructions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 5/18/2009 10:13:03 PM GMT
It saves a few instructions, but the readability goes way down [noparse][[/noparse]8^)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
Follow-up: I whipped up a quick test program and verified that it works, Jonathan; and, as setup starts clean, I could drop the AND.
Post Edited (JonnyMac) : 5/19/2009 12:47:37 AM GMT
Andy
Post Edited (JonnyMac) : 5/19/2009 1:23:14 AM GMT
yes, Ariba's approach is going to execute the fastest. The example that he gave though uses a reserved Spin variable 'lookup'
that might have been causing you some problems. Here is the same code demonstrating the LEDs on the DEMO board.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (JonnyMac) : 5/19/2009 4:01:11 AM GMT
"mov ch, #3 ' <-change this value from 0 to 3"
Does this line of code point to third value from the left in the "#table" which is %1101?
"add look_up, #table"
I see this line of code points to the table correct?
Also if I wanted to make two tables then I could do this?
In fact this adds the table base address to the index to form the final element address (base+index).
If you want more than one table then simply change the base address (i.e. use a different one). You could also merge the tables and adjust the index accordingly. For example in your code fragment using index 4 and base table is equivalent to using index 0 and base table1.
I see what you are saying about the zero base 3 is the 4th entry.
So what you are saying is that index 4 ,base adress table is pointing to the same as index 0, base adress table1 which is %0001 this is because the longs are inline correct?
So as long as they are not seperated with a different long then the index is just added to the base adress of the first long table?
Exactly. You may want to consider using different tables anyway depending on what they are used for. Otherwise you get confused later (after a few month) when you review your code Like why is index 4 referring to the first entry?
Thanks for the help I believe I understand it now.
Ariba's code
Beau's code
Sandy