Search code examples
cpuoperationalu

What are the ALU operations in CPU?


Besides the common operations of alu like (add,substract,multiplier,and,or,xor,not) what other operations does it have or where can i get a list wih all operations of a cpu ??


Solution

  • You can usually deduce this from the instruction set as found in the programmer's manual.

    Depending on how that is written, it may take a little care to distinguish operations of the main (traditional) ALU from those of accessory units such as floating point engines. Or that may be clear with the different classes of operations being in different sections of the manual, or explicitly marked. Often different registers or instruction formats are utilized as well.

    An obvious class of traditional ALU operation missing from your list but present on most devices is shifts and rotates. These are even more commonly supported than hardware multiplication.

    Another is "move", "load", or "store" type operations. Often (at least in historic designs) these pass through the ALU with some setting that makes the output merely match one of the inputs. In some cases these would be explicitly encoded in the instruction word as some null operation such as adding zero, OR'ing the input with itself, or AND'ing with an all-ones constant register. In others the pass-through is configured internally by the instruction decode logic. Further confusing things, you can have an instruction mnemonic for human use which looks distinct, but is actually encoded as an instruction word which is merely a special case of something more generic. Furthering that theme, stack operations may follow a similar path, and may be either distinct or friendly mnemonics for a special case of load/store.