如何在汇编中将正数转换为负数 [英] How to convert a positive number to negative in assembly
本文介绍了如何在汇编中将正数转换为负数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在汇编中将正数转换为负数, 我需要一个代码示例
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
这篇关于如何在汇编中将正数转换为负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文