12/5/2012 1:30 PM | |
Joined: 10/7/2005 Last visit: 8/9/2024 Posts: 3016 Rating:
|
Hello Elonen even though I'm don't know for what purpose you think you need to do this, here's my take on how it can be done (as you probably are aware, type checking of addresses is pretty thourough in Dist. Safety so you need toemploy the "MOVE" "trick" to overcome it). 1.)Is it possible to determine if INT is odd or even? Yes, as followed Move INT to a WORD variable Use "WAND_W" instruction to "word AND" a constant of W#16#1 with above WORD variable Move resulting WORD variable to an INT variable Use "EQ_I" comparator to see if above INT avariable is 0 (if yes then the orignal INT is even, in no it is odd) 2) Is it possible to add 1 (or n) to a Word? Yes, as followed Move WORD to an INT variable Use "ADD_I" instruction to add 1 to it Check for Overflow (optional but recommend) Use the INT result as you see fit (or move back to a WORD variable) I hope this helps |
Cheers |
|
This contribution was helpful to
3 thankful Users |
7/21/2016 2:02 PM | |
Joined: 9/3/2014 Last visit: 3/13/2019 Posts: 4767 Rating:
|
New question published by GaJEnDrA D S is split to a separate thread with the subject How to check EVEN ODD numbers in V11 sp2 update 5?. Best regards |
Follow us on