Chapter 2: Arithmetic Logic Unit Flashcards

1
Q

What does the ALU do?

A

The ALU will perform an operation on its inputs to create a single output value.

Usually, there are two inputs and one destination. The flags in the status register may be affected by the operation. However, which operations affect which flags is processor dependent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The two types of addition performed by ALU?

A

Addition simply takes the two inputs and adds them together. An “Add with carry” operation is usually included that adds the carry input as well.

This is used to enable multi-word operation. A new carry output is also produced. The same process applies to both signed and unsigned integers. However, if an overflow occurs, then you will know that the result will be incorrect if they were signed numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does the ALU subtract?

A

Subtraction simply takes the two inputs and subtracts one from the other. It is usually achieved by taking the one’s or two’s complement of one input and feeding the inputs to the adder.

A Subtract with carry operation is usually included that takes account of the carry/borrow bit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ALU comparison?

A

A compare simply takes the two inputs and subtracts one from the other. This is achieved in exactly the same way as a subtraction: Source A – Source B. There is no need for a destination since the flags provide the result:

  • Zero – Values are the same
  • Carry/Borrow (if a borrow has occurred, C=0, otherwise C=1), Negative and Overflow – Which is bigger
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ALU Negate?

A

This create the two’s complement of a number. Simply works by using the subtractor with one of the inputs set to zero, so that it calculates 0 – number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ALU Multiply with 2 numbers?

A

Multiplying two N bit numbers together produces a 2N bit result.

Sometimes the low and high parts of the result are stored in different registers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ALU Multiply with 3 numbers

A

Sometimes a special multiply and add or MAC instruction is provided. In this case there are 3 sources and 2 destinations. This instruction is very useful for quick signal processing. However both the multiply and MAC instructions are often not available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

ALU Divide?

A

Division can produce a result and a remainder so that 2 destinations can be used. This operation is often not available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ALU Logic?

A
  • All the standard logic operations will normally be provided, such as AND, OR, NOT, XOR. They operate bitwise between the two sources.
  • Another set of instructions can be used to test, set or clear individual bits. These are useful to test, set or clear flags.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

ALU Shits?

A

Shifting takes a single source and moves all bits up or down the word. Shift left is equivalent to multiplying the number by 2, whereas shifting right is equivalent to dividing by 2.

For right shifts it is likely that sign extension is required to make sure the bit made vacant by the shift is correct. However often it is not available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ALU Rotate?

A

Rotate left and right are similar to shift. However the bit moved off one end is used in the vacant space at the other. Rotate through the carry bit is sometimes also available. This instruction is useful for bit manipulation. However often it is not available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

ALU SIMD

A

(Single Instruction, Multiple Data)

This is a useful type of instruction for when the same operation is to be done on a large set of data points, such as increasing the brightness in an image or increasing the volume in a digital audio data file. They can speed up the performance of computers. These instructions are quite recent additions to microprocessor architectures, with their introduction driven strongly by video games and video processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe how flags can be used to determine the result of a compare operation between two unsigned integers in an ALU?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly