Legacy apps in Windows/OS X was Re: Old MS-DOS & Win Software

Chuck Guzis cclist at sydex.com
Thu Dec 8 11:38:13 CST 2005

On 12/8/2005 at 12:21 AM Patrick Finnegan wrote:

>Sure there's a reason.  JCXZ is one instruction, and (probably) uses up 
>less code space than the other.  You could "AND CX,CX" and do a JZ 
>afterwards to do the same thing.

Well, not exactly.  JCXZ doesn't affect the condition codes, nor does it
rely on them.  And on most x86 platforms, starting with the 386, it tends
to be slower than something like a AND CX,CX  JZ sequence (which does
affect the status flags).  So why does it exist?  I belive it was intended
for loop control when condition code preservation is important.  Note that
there's no JCXNZ instruction, nor a specific test-and-jump on any other

It's a problem with instruction sets that implement result codes as a
simple condition code register.  The same arithmetic that couints
interations affects the condition codes that one might also need for
searching or computation.  That's probably the reason that the increment
and decrement instructions don't bother the carry flag and that the 16-bit
increments and decrements on the 8080 didn't bother any of the condition
codes.  Inspection of the 808x instruction set can be very illuminiating,
particularly when it comes to arcana like which instructions modify (and
how) the half-carry flag, for example.


More information about the cctech mailing list