In: Computer Science
This is a three-part question. If you want it piecemeal, then let me know.
Assume that R31, R30, ... , R0 are the 32 ALU result bits output by our MIPS ALU.
a) Write down a logic expression for the Z (zero) flag that indicates when the result is zero as a function of these 32 result bits.
b) Write down a logic expression for an N (negative) flag that indicates whether the result is negative.
c) Suppose that there were four flags Z, N, V, and C (for zero, negative, overflow and carry). After the instruction sub $t0,$t1,$t2 which subtracts $t2 from $t1 and places the result into $t0, what combination of the flags (Z, N, V, C) indicates that $t1 contains a value less than that in $t2? Write down the logic expression for LESS as a function of Z, N, V and C. LESS = __________________
(a) zero (Z)flag is a status resistor that check for the result
of an arithmetic operation is zero or not ,if the result is zero
then the value of the flag is one(1) else value is zero(0)
we can check the status of zero flag using JZ(jump if zero).
example:
JZ label ;//jump to label if zero flag is set
label:....
(b) Negative (N) flag is also a status check resistor ,is check
the value of an operation is negative or not ,when the result is
negative then N flag is set(1) else it is zero(0).
we can check the status of zero flag using JS(Jump Sign (negative
value)).
JS label ;//jump to label(memory location) if N flag is set
label:.....
(c) we have subtraction s0=s1-s2;
And we have to check that the value of s1 is less then s2 or
not.
So when s1 is less than s2 then value of s0 is negative and that we
can check using Negative(N) flag ,when S0 is negative then the
value of N flag is one(1)else it is zero(0).
SUB destination, source
code:
MOV A,s1
MOV B,s2
SUB A,B ;//this subtract s1-s2 and assign the result in A
JS label ;//if result of last operation is negative the move to
label
label:....
overflow flag only affectec when 1.pos+pos = neg
2.neg+neg = pos
LESS=!Z && C && N