Bug in bit comparisons in SX/B
Michael Chadwick
Posts: 80
Hi All,
Whilst using SX/B to do a quick test program, I ran across this bug as shown by the list file:
·· 298· 00F5· 0068······· CLR __PARAM1·················· ;if RO_485<>~byte_sent.0 then
·· 299· 00F6· 0607······· ADDB __PARAM1,RO_485·········
· ······· 00F7· 02A8
·· 300· 00F8· 060F······· ADDB __PARAM1,byte_sent.0····
··· ····· 00F9· 02A8
·· 301· 00FA· 0708······· JNB __PARAM1.0,@__ELSE_2·····
····· ··· 00FB· 0010 0B0E
The compiler doesn't complain about the NOT (~) in front of the second variable, but doesn't generate
the correct code for the bit adds.· Which should have been ADDB __PARAM1,/byte_sent.0.
It·doesn't seem to work for any comparison using NOT in front of a bit variable.
MRC
Whilst using SX/B to do a quick test program, I ran across this bug as shown by the list file:
·· 298· 00F5· 0068······· CLR __PARAM1·················· ;if RO_485<>~byte_sent.0 then
·· 299· 00F6· 0607······· ADDB __PARAM1,RO_485·········
· ······· 00F7· 02A8
·· 300· 00F8· 060F······· ADDB __PARAM1,byte_sent.0····
··· ····· 00F9· 02A8
·· 301· 00FA· 0708······· JNB __PARAM1.0,@__ELSE_2·····
····· ··· 00FB· 0010 0B0E
The compiler doesn't complain about the NOT (~) in front of the second variable, but doesn't generate
the correct code for the bit adds.· Which should have been ADDB __PARAM1,/byte_sent.0.
It·doesn't seem to work for any comparison using NOT in front of a bit variable.
MRC
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Yeah it seems you confused the poor compiler. Your line would make more sense as "if RO_485 = byte_send.0 then" wouldn't it.
But your right it should have worked the way you had it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"If I was king for just one day...I don't think I could screw things up any worse [noparse];)[/noparse]"
Post Edited (Bean (Hitt Consulting)) : 1/8/2006 12:19:10 AM GMT
Yeah, I could have coded it that way, but in the context of the program ~byte_sent.0 had been copied to a pin that looped back to RO_485 (an input) a couple of microseconds before, and I was checking to see if it wasn't what it was supposed to be so I could flag an error. The not equals was the best representation of the intent of the code.
This was supposed to be a *quick* test of something, which I have found to be an excellent use of SX/B. When it didn't work as expected, always indicating an error, I investigated further and found the code wasn't being generated as expected.
I'm really surprised that no-one else has run into this. Maybe I just code strangely [noparse]:)[/noparse]
This was SX/B version 1.42 by the way.
I do want to point out that you guys have done a terrific job on the IDE and SX/B! I know the forums tend to be mostly bug reports or things that don't work as expected, because that's when people feel the need to write. But please don't think for a minute your hard work, dedication and enthusiasm isn't appreciated. It is, a lot. Thanks for the terrific tools!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
MRC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax