MIPS 汇编中的 nand 位运算

发布于 2024-11-05 10:44:14 字数 294 浏览 8 评论 0原文

我一直试图弄清楚如何在汇编中进行 nand 按位运算,但没有成功。我试图编写一个逻辑门模拟器,它本质上会为输入 A 和 B 生成这个真值表,

   A  |   B  ||  F
  -----------------
   lo |  lo  ||  hi
   lo |  hi  ||  hi
   hi |  lo  ||  hi
   hi |  hi  ||  lo

我已经尝试了一切。

  and  $t3,$t1,$t  
  not  $t4,$t3

无法产生正确的输出

I've been trying to figure out how to do a nand bitwise operation in assembly but have been unsuccessful. I'm tried to write a logic gate simulator that will essentially produce this truth table for inputs A and B


   A  |   B  ||  F
  -----------------
   lo |  lo  ||  hi
   lo |  hi  ||  hi
   hi |  lo  ||  hi
   hi |  hi  ||  lo

I've tried everything.

  and  $t3,$t1,$t  
  not  $t4,$t3

Does not produce the correct output

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗化ㄋ丶相逢 2024-11-12 10:44:14

当然是这样,看看真值表:

A    B    And   Nand
---------------------
lo   lo   lo    hi
lo   hi   lo    hi
hi   lo   lo    hi
hi   hi   hi    lo

如您所见,您可以通过否定先前的与值来获得 nand 值。但您可能忘记了andnot对寄存器的每一位进行操作。我认为您对布尔值感到困惑,其中(通常)任何非零值都被假定为真。因此,

   11101001 nand 01000111 = 
 = ~ (11101001 and 01000111) =
 = ~ 01000001 = 
 = 10111110

因为

1 and 0 = 0
1 and 1 = 1
1 and 0 = 0
0 and 0 = 0
1 and 0 = 0
0 and 1 = 0
0 and 1 = 0
1 and 1 = 1

下次您也应该发布预期结果和实际结果,这样我们就更容易理解出了什么问题。

OF course it does, look at the truth table:

A    B    And   Nand
---------------------
lo   lo   lo    hi
lo   hi   lo    hi
hi   lo   lo    hi
hi   hi   hi    lo

As you can see, you can get nand values by negating previously anded values. But you may have forgotten that and and not operate on each bit of the registers. I think you confused with boolean values, where (usually) any non-zero value is assumed to be true. Therefore,

   11101001 nand 01000111 = 
 = ~ (11101001 and 01000111) =
 = ~ 01000001 = 
 = 10111110

because

1 and 0 = 0
1 and 1 = 1
1 and 0 = 0
0 and 0 = 0
1 and 0 = 0
0 and 1 = 0
0 and 1 = 0
1 and 1 = 1

Next time you should post both expected and actual results too, this way it is easier for us to understand what went wrong.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文