Picaxe Logicl Operators question

JSDL

Senior Member
Hi there, I have a general question about the order of operations with Picaxe logical operators. I understand that Picaxe maths are executed left to right with no order of operations (correct me if I am wrong), but does this apply to Logical Operators as well? I have extracted a line of code from a book:

Code:
pins=outbyte & $F0 | 2 | rs
Assuming outbyte=$80 and rs=0, is the correct order of logical operations as follows:

1. Logical AND outbyte with $F0, resulting in pins=%10000000 | 2 | rs
2. Logical OR %10000000 with %00000010 resulting in pins=%100000010 | rs
3. Logical OR %100000010 resulting in pins=%100000010

Please let me know if I am correct in my understanding.

Also, another question regarding TABLES/EEPROM/LOOKUP:

What are the advantages/disadvantages in terms of speed and memory management between using TABLES vs EEPROM vs. LOOKUP to push commands/data to a parallel LCDs? Is one preferred over the other? Thanks for any advice you can provide.
 

hippy

Ex-Staff (retired)
Yes, all operations are strictly left to right, including logical. In your example it is therefore AND, then OR, and a further OR as you understand it to be.

The advantages of EEPROM and TABLE over LOOKUP is that they are quicker to execute when execution time is important, and use less program memory, at the cost of slightly longer download times and sometimes reduced program code size.

For a short LOOKUP, such as LCD initialisation, LOOKUP is just as good as READ/READTABLE, especially as there needs to be pauses between commands so no gain from faster execution.

LOOKUP might also be preferred if EEPROM/TABLE were needed for other things, such as pre-programmed or non-volatile message storage.
 
Top