Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前在尝试将来自模块输入的 16 位数字存储到我的逻辑变量之一时遇到问题。当我在测试台上将所有位设置为高时,我得到一个值:0000000000000001。希望您能提供帮助!PS:对不起,不知道如何在这里插入代码......
我的代码如下所示:
http://pastebin.com/cZCYKJqV
我认为您的问题可能与这条线有关:
regy = (!regy)+1;
regy是一个 16 位的值。(!)对多位值使用否定运算符等效于(value != 0). 因此,对于regy除零以外的任何值都将设置regy为 1。
regy
(!)
(value != 0)
如果您尝试反转所有位并加 1,则需要使用~运算符。
~
例子:
regy = (~regy)+1;