且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在汇编中将正数转换为负数

更新时间:2022-01-25 23:03:07

嗯,有两种方法可以做到这一点,***是将数字加载到寄存器中,然后像汉斯所说的那样使用NEG指令,即:NEG EAX将否定eax.另一种方法是XOR EAX,EAX SUB EAX,EDX,其中edx包含您要取反的数字

Well, there are two ways to do this, best would be to load the number into a register, then use the NEG instruction as Hans mention, ie: NEG EAX would negate eax. The other way would be XOR EAX,EAX SUB EAX,EDX where edx contains the number you want to negate