I want to know if the NEG instruction affects the overflow flag too. I know that it negates the value of a variable, but couldn't find out whether it affects the Overflow flag or not.
does NEG instruction in assembly language sets the Overflow flag
3k Views Asked by k112275 Uzaif Umer At
2
There are 2 best solutions below
Related Questions in ASSEMBLY
- (x64 Nasm) Writeline function on Linux
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- Why do we need AX instead of MOV DS, data directly with a segment?
- Bootloader in Assembly with Linux kernel
- How should the byte sequence 0x40 0x55 be interpreted by an x86-64 emulator?
- C++ code into assembly
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- Equivalent to asm volatile in Gfortran?
- Show 640x480 BMP image with inline ASM c++
- Keep track of numbers entered in by a user in assembly
- 8086 Assembly Arrays with I/O
- DB ASM variable in Inline ASM C++
- What does Jump to means in callgrind?
- How to convert binary into decimal in assembly x8086?
Related Questions in X86
- Why do we need AX instead of MOV DS, data directly with a segment?
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- How to add values from vector to each other
- Intel x64 instructions CMPSB/CMPSW/CMPSD/CMPSQ
- Compact implementation of logical AND in x86 assembly
- Can feenableexcept hurt a program performance?
- How do I display the result and remainder in ax and dx in Assembly (tasm)
- ASM : Trouble using int21h on real machine
- jmp instruction *%eax
- What steps are needed to load a second stage bootloader by name on a FAT32 file system in x86 Assembly?
- Assembly code to print a new line string
- Write System Call Argument Registers
- How to jump to an address saved in a register in intel assembly?
- Find middle value of a list
Related Questions in MASM32
- Change border color of Rectangle function in c++
- Displaying symbolic constants in Assembly Language
- Why Masm32 only give 1 to 100 result for add and subtraction operation and beyond that I got wrong answer?
- Read bytes from Dump in Masm
- error: invalid instruction operand (on .ENDW)
- Decimal value in masm32
- copy string procedure assembly
- Using stack in windows MASM program
- Get structure size within MASM
- Where is the MASM SDK?
- How do I use ReadString in Assembly?
- How to run a MS-DOS .asm file using VS2013 or MASM32?
- How do I implement a 'double buffer' for my sprites in graphics mode in assembly?
- Assembly compilation failed using NASM on Windows 7 x64
- MASM infinite loop
Related Questions in EFLAGS
- How are the carry and overflow flags used to calculate multiplication in x86
- When is the overflow flag used?
- Why is the overflow flag not being set in this example?
- How to set carry flag in specific bit in GPR without shifts / rotations?
- How to set SF with pushfq and popfq
- Why is the Overflow-Flag only set when single shifts are used?
- Assembly pushf,pop commands, sub changig result?
- does single step interrupt(01H interrupt) clear TF flag after every instruction?
- Why doesn't mov set the zero flag?
- What is the default value of the Zero Flag in x86 assembly MASM?
- Why parity flag is 1 while number of ones is odd
- Why auxiliary flag is 0 when there is a borrow between nibbles
- State of EFLAGS
- Conditions under which EFLAGS flags are set in x86/x64
- Sign, Carry, and Overflow Flag (Assembly)
Related Questions in SIGNED-OVERFLOW
- Why is the overflow flag not being set in this example?
- Overflow and Carry flags on Z80
- Sign, Carry, and Overflow Flag (Assembly)
- Understanding the difference between overflow and carry flags
- When is Overflow flag set?
- Why does cmp 0x84,0x30 trigger the overflow flag?
- Assembly - Carry flag VS overflow flag
- Why signed integer overflow in c++ is undefined rather than implementation-defined?
- Checking for overflow and/or carry flags, getting an integer code of which happened
- how to determine if overflow flag is turned on/off for mixed sign binary addition?
- Is there a safe way to get the unsigned absolute value of a signed integer, without triggering overflow?
- does NEG instruction in assembly language sets the Overflow flag
- C: Undefined behavior when multiplying uint16_t?
- Why does std::push_heap generate a -Wstrict-overflow=3 warning even if no signed types are involved?
- x86 left shift arithmetically overflow control
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If you want to know what instructions do, consult the reference manuals.
The essential reference, namely the Intel instruction set manual says this about the NEG instruction:
So it is clear that the NEG instruction sets the O flag; therefore it affects the O flag, which is the OP's original question. And it does so every time it is executed. (People should not confuse "didn't change" from "not set").
That particular reference manual doesn't provide a specific algorithm to indicate when O is set to zero or one. However, Intel CPUs are 2's complement machines. The Subtract instruction has the exact same verbiage. NEG X is equivalent to (0 SUBTRACT X). So NEG should set the O bit according to "overflow" for (0 SUBTRACT X); this will set O when X is 0x8000000.
Inspecting the Intel Basic Archiecture Manual, we find this description of the OF bit:
confirming our understanding.