3 ms·
This quine is a bit of cheating. It reads its own memory and dumps it. It is like “10 LIST” quine. For the machine code, the memory is THE source, and this co
by begoon 4y ago
This quine is a bit of cheating. It reads its own memory and dumps it.
It is like “10 LIST” quine.
For the machine code, the memory is THE source, and this code simply reads it because it can.
Imagine a quine in machine code running on an architecture where it is not allowed to read the code segment. This quine will not work there.
The REAL quine should generate the output purely via output data transformation encoded INTO the source, without any assumption of the runtime.
- schoen 4y agoWhile this criticism seems valid to me, it's also hard to define what it means for a machine-code quine not to be allowed to access its own memory, as machine code, for example, normally prints strings using pointers to copies of those strings stored in memory. Those strings might or might not be kept in a different segment, depending on the architecture, but can you define "machine code" in an abstract enough way to allow some kind of string printing in general without self-reference?
- deredede 4y agoTake the set of addresses that are pointed to by the program counter during execution. They are off-limit. Things are a bit more murky with variable-length instructions, but basically you are not allowed to read as data any address that is ever read as part of instruction decoding.
- schoen 4y ago> Take the set of addresses that are pointed to by the program counter during execution. They are off-limit. How do you know which addresses those will be? If the underlying architecture and OS permit reads or writes of code segments and/or execution of data segments, this set of addresses is literally undecidable.
- deredede 4y agoSorry for the late reply. It doesn't matter that this set of addresses is undecidable: so is the halting problem and yet we can precisely define the set of halting programs. You don't have to know these adresses beforehand, so you can just run the program to collect them and check. Or you roll up your sleeves and do some maths to compute (an overapproximation of) that set for the specific program you're interested in, which may be your only option if your architecture is nondeterministic.
- dividuum 4y agoThis is discussed at length in the blog post itself: https://susam.net/blog/self-printing-machine-code.html#quine-conundrums https://susam.net/blog/self-printing-machine-code.html#quine.... A non-cheating quine is provided as well.