
MOV is Turing-complete (2013) [pdf] - susam
http://drwho.virtadpt.net/files/mov.pdf
======
Zecc
I honest to goodness thought this was going to be about the video container
format. In retrospect this makes much more snse.

~~~
dehrmann
Isn't PDF almost Turing-complete?

~~~
2038AD
I believe at least doubly so (in addition to postscript you can embed
JavaScript)

------
a-wu
relevant:

Chris Domas' movfuscator:
[https://github.com/xoreaxeaxeax/movfuscator](https://github.com/xoreaxeaxeax/movfuscator)

Presentation:
[https://www.youtube.com/watch?v=R7EEoWg6Ekk](https://www.youtube.com/watch?v=R7EEoWg6Ekk)

~~~
caleb-allen
I wish Chris Domas still did presentations. I believe he was hired by Intel
and I would guess that they would have asked him to stop publicly presenting.

Smart hire on their part, but his presentations are legendary to me!

------
claudiawerner
A related project: the movfuscator, which converts programs into "mov
instructions, and only mov instructions":
[https://github.com/xoreaxeaxeax/movfuscator](https://github.com/xoreaxeaxeax/movfuscator)

"The inspiration for the compiler is the paper "mov is Turing-complete", by
Stephen Dolan."

------
dang
2015:
[https://news.ycombinator.com/item?id=9751312](https://news.ycombinator.com/item?id=9751312)

2013:
[https://news.ycombinator.com/item?id=6309631](https://news.ycombinator.com/item?id=6309631)

(Links are for the curious. Reposts are fine after a year or so:
[https://news.ycombinator.com/newsfaq.html](https://news.ycombinator.com/newsfaq.html))

------
nneonneo
It’s actually a shame that there is no `mov rip, ...` instruction. That would
make it truly Turing-complete. ARM has this instruction! (Of course, jmp [...]
works just as well, but it isn’t called mov)

~~~
shakna
Movfuscator [0] (which expands on the paper) managed to find a way to jump
using just mov - by using a faulting mov.

[0]
[https://github.com/xoreaxeaxeax/movfuscator](https://github.com/xoreaxeaxeax/movfuscator)

~~~
nneonneo
Yeah, I remember this. It requires setting up a custom signal handler though.
IIRC something similar is used to get system/library calls (which also can’t
be expressed purely with mov instructions, normally).

If I recall correctly tom7 had a cute trick to get looping behavior in his
ASCII-only compiler for 16-bit Intel
([http://tom7.org/abc/](http://tom7.org/abc/)) which was to make the program
64KB exactly, such that the program counter just loops around at the end. I
suppose that’s another option to get _pure_ mov-only code.

------
octocop
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?

~~~
Liquid_Fire
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.

~~~
nexuist
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?

~~~
magicalhippo
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.

------
begoon
[https://pragprog.com/magazines/2012-03/the-nor-
machine](https://pragprog.com/magazines/2012-03/the-nor-machine)

------
svnpenn
FYI is the same Stephen Dolan from here:

[https://github.com/stedolan/jq](https://github.com/stedolan/jq)

