问题
In my class we are translating C to MIPS.
We are asked to translate this snippet:
A = A ? B : C[0]
I believe I understand the ternary operator, but what is wanted here? Shouldn't A be a boolean? So would it be represented in MIPS with a 1 or 0 value?
Thank you
回答1:
It might help to translate the ternary expression to pseudo code first, e.g.:
if A != 0 // if A is non-zero, i.e. TRUE
A = B
else // otherwise A is zero, i.e. FALSE
A = C[0]
来源:https://stackoverflow.com/questions/28160408/translating-c-to-mips-with-a-ternary-operator