Re:MOV is Turing-complete (2013) [pdf]
by octocop on Tuesday February 18, 2020 @07:28AM
(#22355458)
I did not understand how mov could be used for comparison. Is a register set to a certain value if the contents are already the same value when it's trying to write?
[ Parent
| on HN ]
Re:MOV is Turing-complete (2013) [pdf]
by Liquid_Fire on Tuesday February 18, 2020 @07:37AM
(#22355493)
If you are comparing values X and Y, just write 0 to address X and 1 to address Y. Then read address X.
If X and Y are equal, then you would have written first 0 and then 1 to the same address, so the final read would give you 1.
If X and Y are different, then you would read back the 0 you wrote to address X.
It took me a bit to grok this but I think I finally understand it. Super clever.
Now, how would you do greater than / less than comparisons?
Re:MOV is Turing-complete (2013) [pdf]
by magicalhippo on Tuesday February 18, 2020 @04:05PM
(#22360395)
The native and super inefficient way would be basically the same: write 1 to all addresses greater or equal to X, and 0 to all addresses less than X, then read from address Y and see what you end up with.
Probably a more clever trick out there though.
No, it's testing "did this MOV clobber address X or not."
Put a guard value in address X. Write not-guard value to Y. Read X. If the value you just read wasn't the guard value, then Y was the same as X.