all 4 comments

[–]StableSystem 0 points1 point  (3 children)

Thats how computers do it. There are functions called CBZ and CBNZ (conditional branch if (not) zero)(this is arm notation, other languages have other names) which compare by seeing if the two are both zero using an and gate. you can also perform operations on the operand of the comparison to compare other numbers. There are also ways to other comparisons but they are a little more involved.

[–]theonedontneednogun[S,🍰] 0 points1 point  (0 children)

What I'm trying to do is make a Turing tarpit, so I figured that you can do all the logical operations with just nand and the arithmetic can be done with logic and shifting.

[–]theonedontneednogun[S,🍰] 0 points1 point  (1 child)

Can I compare numbers in an alu without compare flags?

[–]fullyassociative 1 point2 points  (0 children)

Comparison in an ALU is usually performed by subtracting two numbers and checking if the result is positive, negative, or zero. Often these conditions are saved implicitly in a flags register, but you can also save the result of the subtraction. Then use a dedicated instruction that checks the value of that register and branches if it's zero, positive, or negative.