Search code examples
assemblyx86fasm

Where does neg store the reversed number?


I'm reading a book about assembly x86 on the FASM assembler and the following sentence is introduced:

neg subtracts a signed integer operand from zero. The effect of this instructon is to reverse the sign of the operand from positive to negative or from negative to positive.

It subtracts the operand from 0, so if I have 6 ,(0-6=-6) and if I have -6 (0-(-6)=6)

Now, where does it save the reversed number? In the given operand? It doesn't say anymore about it in the book, so here I am wondering what's its purpose if we can't store it.


Solution

  • I think the author of the book assumed it was obvious that it was stored somewhere, and the only logical place is back into the given operand, like INC / DEC and NOT.

    As you say, it wouldn't make much sense if it didn't store it anywhere.

    And your book is presumably not trying to be an ISA reference manual; Intel and AMD publish those (for free as PDF) and you should consult them any time you aren't sure about something like this.

    See https://stackoverflow.com/tags/x86/info for links to docs.