How do ALU flags communicate with the rest of the computer

aluassemblycomputershacking

How are ALU flags connected to various parts of a computer? I've just finished building an 8 bit computer in Logisim that can add subtract and compare… and am wondering how I can make it multiply (in software) using ALU flags.

Best Answer

There are two common ways for flags to influence instructions:

  • influence on the control flow, in the form of a condition skip (eg. skip the next instruction if the carry flag is set), or conditional jmp/goto (conditional call and condtional return are more rare but do exist)

  • influence on the data, which is most common in shifts (shift in from the carry bit, and/or shift out to the carry bit), an add-with-carry instruction (and likewise subtract-with-carry) which are both very usefull in implementing shits, add, and substract on data that is larger than the natural size of the CPU

The ARM achitecture took the first idea to the extreme: every instruction had a condition field that specified under which flag settings the instruction was executed. If the flag settings were different, the instruction had no effect (executed as a NOP). This avoided a lot of branches (both conditional and non-conditional) in the control flow, which is important for a pipelined CPU.

Related Topic