[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v7 2/5] x86/asm: add volatile, clobbers and zero-length check in inline memcmp



On Thu, 23 Jul 2026 20:49:13 -0400
Brian Gerst <brgerst@xxxxxxxxx> wrote:

...
> I had originally thought that the test for RCX==0 was also at the end
> of the loop, after the decrement.  But a closer look at the
> pseudo-code in the SDM does show that the test is at the start of the
> loop.  Starting with RCX==0 does indeed skip the comparison and does
> not touch ZF.  Your suggestion is good, but should have a comment
> explaining why it's there to someone reading the code in the future.

I have a feeling that was a change between the 8086 and 80286.
I don't have an 8086 book (any more) but I'm sure I remember fixing
bugs where %cx of zero caused 65536 iterations.
(Fun to find because the vector table is 'first in the line to be
overwritten.)

        David



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.