I have been taking a course called nand2tetris. In it, we build a 16-bit computer, and in each instruction, the first bit chooses address mode or command mode, i.e., if it's 0, then we load the address register, if it's 1, we execute an instruction. The last 3 bits specify the jump condition (based on ALU output) like so:
000 - no jump
001 - jump if greater than 0
010 - jump if equal to 0
011 - jump if greater than or equal to 0
100 - jump if less than 0
101 - jump if not equal to 0
110 - jump if less than or equal to 0
111 - jump
Suppose I'm making an 8-bit computer, and I only have 1 bit to specify the jump instruction. If it's 0, don't jump, if it's 1, then jump if ALU output is 0. How will I do the other comparisons? My guess was to store conditions in registers, i.e., ALU stores "greater than" (0 if true else 1) in register 0, "greater than or equal to" in register 1, "less than" in register 2, and so on. When I want to check for inequality, I load the value in the address register and jump if it's 0.
// greater than or equal to loaded in address register
// below is equivalent to ld 0x03
ld geq
// set D register to value in geq
mv D M
// "loop" line address loaded in address register
ld loop
// goto "loop" if D is 0 else continue
D: jp
Is this right approach? This is 4 lines of instruction compared to single line to specify jump specification in the 16-bit computer! There has to be a simple better way to specify.