【问题标题】:Cannot solve mips with and, or, and xor operators无法使用 and、or 和 xor 运算符解决 mips
【发布时间】:2014-09-30 17:51:50
【问题描述】:

我被这个问题困住了,需要帮助。我有两个寄存器

$t2 是 00000000 00000000 00000000 01111001

$t3 即 11111111 11111111 11111111 11100011

被问到的三个问题是(答案必须是二进制)

和$s2,$t2,$t3

或$s2,$t2,$t3

xor $s2,$t2,$t3

我在网上和我的教科书中到处找遍了,但我终其一生都无法弄清楚这些操作员是做什么的。我不是在寻求答案,而只是寻求一些关于我应该如何开始解决这些问题的指导。

谢谢。

【问题讨论】:

标签: assembly bit-manipulation mips operator-keyword xor


【解决方案1】:

这些是位运算符。他们的名字来源于他们实现的逻辑门/布尔数学运算符:

AND => both inputs true (1) generates true
OR  => any input true generates true
XOR => true only if one input is true and the other is false

有关运算符的更多信息,请参阅维基百科文章:

因为这些是非常基本的布尔运算符/逻辑门,所以在有关 CPU 设计和汇编编程的书籍/文本中通常假定读者熟悉它们。或许不应该做出这样的假设,因为如今编程是一门更广泛的学科,涵盖了从生物学家到股票市场分析师再到工程师的方方面面。

在将运算符应用于一串位(例如一个字或一个字节)时,两个输入中的所有位都是并行处理的。例如,让我们对两个字节进行 AND:

input 1 = 11110000
input 2 = 00111100
------------------
output  = 00110000
            ▲▲
            ││
            └┴──────── true because both bits from
                       input 1 and input 2 are true
                       (see difinition of AND)

其他运算符也是如此。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-13
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-12
    • 1970-01-01
    相关资源
    最近更新 更多