Problem with the NOT operator for array elements in SX/B VERSION 1.51.02
RonW
Posts: 39
The SX/B NOT operator in 1.51.02 has a problem. When both the operand and the result are array elements, the assembly code generated by the compiler inverts the operand twice.
Here's the code I used to confirm this:
ByteArray VAR Byte(2)
Element0 VAR ByteArray(0)
Element1 VAR ByteArray(1)
...
Element0 = 0
Element1 = 0
Element1 = NOT Element0
This code leaves Element1 with a value of $00, not $FF as expected.
Of course a simple work-around is to add a non-array byte variable, such as Temp:
Temp = Element0
Element1 = NOT Temp
I also noticed that "NOT" and "~" are not shown in bold in the basic editor. I believe that's because they aren't listed in RESERVED.TXT.
Here's the code I used to confirm this:
ByteArray VAR Byte(2)
Element0 VAR ByteArray(0)
Element1 VAR ByteArray(1)
...
Element0 = 0
Element1 = 0
Element1 = NOT Element0
This code leaves Element1 with a value of $00, not $FF as expected.
Of course a simple work-around is to add a non-array byte variable, such as Temp:
Temp = Element0
Element1 = NOT Temp
I also noticed that "NOT" and "~" are not shown in bold in the basic editor. I believe that's because they aren't listed in RESERVED.TXT.
Comments
Thanks, I will look into that.
[noparse][[/noparse]edit] Ron, I see what's happening. The value is getting NOT'ed twice. This will be corrected in the next revision.
Thanks again for pointing it out. I put "NOT" in reserved.txt also. Thanks for the catch...
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
There are only two guaranteed ways to become weathy.
Spend less than you make.
Make more than you spend.
Post Edited (Bean (Hitt Consulting)) : 9/25/2006 11:34:49 AM GMT