如何在汇编中将正数转换为负数
问题描述:
我想在汇编中将正数转换为负数, 我需要一个代码示例
I want to convert a positive number to negative in assembly, I need a code sample
输入为十六进制双字
谢谢
答
嗯,有两种方法可以做到这一点,最好是将数字加载到寄存器中,然后像汉斯所说的那样使用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