Why set less than ALU operation

Why is slt considered an ALU operation? I thought it would just subtract and then get the output * Z * ero from ALU?

  ALU control lines |  Function
 ------------------- + -------------------
        0000 |  AND
        0001 |  OR
        0010 |  add
        0110 |  subtract
        0111 |  set on less than

Or ALU should print 1 if the result A - B (in slt $t1, A, B ) is negative.

+5
source share
1 answer

It should output 1 if A is less than b and 0 otherwise. This is often related to AB calculation, for which you need ALU.

Now, if he simply computed the sign bit A - B , it would be superfluous, but consider the case when A = -2147483648 = 0x80000000 and B = 1 = 0x00000001 , here the result of the subtraction will be 0x7fffffff = 2147483647 , which does not have the most significant value bit, even if A < B .

As shown in the table from "Patterson, David A., Hennessy, John L.: Computer Organization and Design." I refer you to chapter 3, in particular the subsection devoted to “additions and subtraction” (3.3 in the 2nd edition, 3.2 in the 4th). It has a table regarding overflow / downstream where you can view corner cabinets.

Also remember that the ALU result is 32 bits, so even if the result was only a signed bit of the subtraction result, it still needs a different ALU operation code to signal that the 31 zeros associated with the result should be returned sooner than the full subtraction result .

The Zero line, which you probably mean, is in the architectures discussed in the book. IIRC is used only for comparisons with respect to an equal branch / non-equal branch. SLT/SLTI in a hand stores its result in the register.

+7
source

All Articles