The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ERNI on August 11, 2005, 09:05:46 AM

Title: inc dec ,and carry flag
Post by: ERNI on August 11, 2005, 09:05:46 AM
Hey

are we know why INC  ,and DEC d't change CARRY flag ,but change ZERO and OVERLOF flags
WHY  :red :eek
Title: Re: inc dec ,and carry flag
Post by: Mirno on August 11, 2005, 09:42:36 AM
Because that is the design.
I'm sure it's more of a pain for Intel now, but the original x86 had those semantics, so they must continue with them.

Mirno
Title: Re: inc dec ,and carry flag
Post by: raymond on August 11, 2005, 02:43:05 PM
I have often found it very usefull that the CARRY flag was not affected by the INC/DEC instructions.

Simply use the SIGN flag if you need to be informed when a register gets decremented below 0 with the DEC instruction. That SIGN is also affected by the INC instruction.

Raymond
Title: Re: inc dec ,and carry flag
Post by: tenkey on August 11, 2005, 05:35:08 PM
Multiprecision arithmetic.

When incrementing addresses and decrementing loop counters, you don't want to destroy the carry/borrow between adds or subtracts.
Title: Re: inc dec ,and carry flag
Post by: Mark Jones on August 11, 2005, 09:00:00 PM
Look in Opcodes.HLP (possibly under JMP):
JC/JNC --> Jump if/not if Carry flag set
JS/JNS --> Jump if/not if Sign flag set