本文介绍了翻译C到MIPS与三元运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的课堂上,我们要翻译C到MIPS。

In my class we are translating C to MIPS.

我们被要求翻译这个片段:
A = A? B:C [0]

We are asked to translate this snippet:A = A ? B : C[0]

我相信我理解的三元运算符,但这里是什么想?如果不是A是一个布尔?在MIPS psented用1或0值,以便将它重新$ P $?

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?

感谢您

推荐答案

这可能有助于第一翻译三元前pression假性code,例如:

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]

这篇关于翻译C到MIPS与三元运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 11:12