this post was submitted on 21 May 2024
1606 points (98.8% liked)

Programmer Humor

32472 readers
949 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 5 points 5 months ago (7 children)

there is an additional layer to this joke for those who understand turing completeness. And it elevates it to a whole other level of snark.

[–] [email protected] 2 points 5 months ago (4 children)

Are you implying that an assembly language consisting of just ret, int3 and jmp (and nop, of course) is turing-complete? ...are you sure about that?

[–] [email protected] 1 points 5 months ago* (last edited 5 months ago) (3 children)

Bookmarking your comment so I can come back to it in a couple hours, if I hopefully remember to.

But yes, almost. I don't think the interrupt is necessary and the return isn't under certain architectures. I have a doc on my computer somewhere where I was investigating what the absolute minimum was to make a turning complete machine and, to my recollection, there was only 4-6 instructions that were absolutely necessary. The ones I remember off the top of my head are NAND, MOV, JUMPIF, and then I believe I included NOP in accordance with some principle. RET and INT were convenience features in this design.

[–] [email protected] 2 points 5 months ago (1 children)

The key here I think is the NAND. I know you can do practically anything with only NAND gates. But without it, and with just control structures, I don't think there's a way to perform computation unless there is some theoretical voodoo withcraft possible, something like nop-padded cellular automata given the infinite memory. But I don't have any qualification to talk about this, I'm just some random dude who flunked out of the university but finished all Zachtronics games.

[–] [email protected] 1 points 5 months ago

You're remembering correctly, every other logic gate can be built from NAND gates, which is the foundation of this sort of minimal-instruction-set exercise. Beyond that, you need to be able to move data and change your program counter (jump, often conditionally). Then, if you want parity with modern instruction sets beyond just being turning complete, you need return and interrupt for control flow.

load more comments (1 replies)
load more comments (1 replies)
load more comments (3 replies)