0

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

   一个 | 乙 || F
  -----------------
   罗 | 罗|| 你好
   罗 | 你好|| 你好
   嗨 | 罗|| 你好
   嗨 | 你好|| 罗

我什么都试过了。

  和 $t3,$t1,$t  
  不是 $t4,$t3

不产生正确的输出

4

1 回答 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.

于 2011-05-05T19:15:03.843 回答