word comparing
Hi,
I made a little test program to compare two 16bit values
and set a true/false result based on the values and
the test to perform (=,<,<=,>,>=,<>)
I would like to know if anybody knows of a faster way (smaller code)
or wether my method can be optimized.
regards peter
Post Edited (Peter Verkaik) : 8/18/2006 11:18:04 AM GMT
I made a little test program to compare two 16bit values
and set a true/false result based on the values and
the test to perform (=,<,<=,>,>=,<>)
I would like to know if anybody knows of a faster way (smaller code)
or wether my method can be optimized.
regards peter
Post Edited (Peter Verkaik) : 8/18/2006 11:18:04 AM GMT
Comments
· I don't know what you're up to, but it looks very interesting...
· I made a couple little changes. If your interested.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
The ramX.15<>ramY.15 takes two more codebytes than the xor method.
For the result, result equals the inverted Z flag (if Z set, result = false)
so I changed that. Saved a few bytes compared to if else.
I also added a asm method which I think is correct. That requires less than 32 codebytes.
The goal is to use this in an expression parser where an expression yields true or false.
regards peter
The assembly code look about as tight as possible. I can't see anything obvious to improve it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
I found a small error, the clr statement affects the Z flag so I had
to make a little change.
regards peter
Strange that MOV W,#0 doesn't affect Z though...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
http://www.sxlist.com/techref/ubicom/lib/flow/compcon_sx.htm
Or did I miss something on that page?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
I got the getUnsignedCompareFlags routine from exactly that page,
only my routine then returns flags for all comparison values.
Then I make a difference between signed and unsigned compare.
I believe the asm routine is correct now.
Please feel free to add it to your page as an example for signed compare.
regards peter
Now, does SX/B not already mange 16 bit comparisons?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!
That's why I had the sxbasic routine first.
The sxbasic and the asm perform the same task.
regards peter
Yes the current version supports word (16-bit) unsigned variables. They are pretty well incorporated in the compiler.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·