In: Computer Science
(a) The 4 common ALU flags occur in most computers. Some computers have additional ALU flags. For example, the x86 flag set includes P, I, and H flags, and the ARM flag set includes T, F, and I. Select two of these additional flags, and research their purpose. Indicate, if appropriate, the logic used to calculate the flag value for a given ALU operation.
(b) An ALU can be used to compare two values, by subtracting the values and consulting the flags. For example, if the two values were the same, the zero flag will be active after they are subtracted. When subtracting A-B, which flags should be active to indicate A<B and A>B for signed numbers? Justify your reasoning.
BONUS: indicate which flags should be active for unsigned comparisons A<B, A>B, A=B
(a) The special flags in X86:
i) H flag:
0011 1001 + 0100 1000 = 1000 0001
The digits which are given in bold are LSB (Least significant bit). Note there is also a bold italic numbers where the carry gets set. So this sets the "Half-carry" flag.
ii) P flag:
b) signed number comparison. We have to take both Overflow flag and sign flag into consideration.
Suppose, if A>B then OF (overflow flag) will be equal to SF (signed Flag)
Suppose, if A<B then OF<>SF
c) Bonus question:
If the number is unsigned then carry flag and zero flag are enough.
A>B carry flag will be 0
A<B carry flag will be 1
if A=B then zero flag will be set to 1.