Computer Organization & Embedded System — Control and Central Processing Units, NEC licence examination syllabus (Nepal Engineering Council).
Where the actual computing happens.
The ALU is the CPU's calculator — a combinational circuit that takes two operand inputs and a function-select code, and produces a result. Depending on the select code, it can perform addition, subtraction, AND, OR, XOR, shifts, and comparisons.
Every ALU operation also updates a small set of status/condition flags — and these flags are what make decision-making in software possible. Every "if" statement you've ever written ultimately depends on one of these four flags being checked.Z (Zero)Set when the result is exactly zero.
C (Carry)Set when an addition overflows the register width, or a subtraction borrows.
S (Sign)Mirrors the most significant bit — tells you if the result is negative in two's complement.
V (Overflow)Set when a SIGNED arithmetic operation produces a result too large to represent correctly.
The chapter says every if-statement depends on the flags. The mechanism is worth spelling out, because it explains why comparison and subtraction are the same operation.
Zero (Z)The result was zero — so in a comparison, the two values were equal.
Carry (C)A carry out of, or borrow into, the most significant bit. For unsigned values this is the less-than test.
Sign (S/N)The most significant bit of the result — negative in two's complement.
Overflow (V)The signed result did not fit. This is the signed counterpart of carry.
The ALU has no memory — outputs depend only on the current inputs, with no clock and no state. All the storage sits in the registers around it.
That is what allows a single ALU to be shared across every instruction: it computes continuously, and the control unit decides which function code to apply and where to route the result. The flags register is the one piece of state, and it exists precisely so a later instruction can act on what an earlier one computed.
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Loading…