🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #188

Re: Performance of xchg reg,reg

#188
From: Anton Ertl
Date: Sun, 18 Oct 2026 16:57
46 lines
3719 bytes
Michael S <already5chosen@yahoo.com> writes:
>On Sun, 18 Oct 2026 15:08:23 GMT
>anton@mips.complang.tuwien.ac.at (Anton Ertl) wrote:
>> I don't think that's the issue here.  They just did not limit the
>> sentence "The XCHG instruction always asserts the LOCK# signal
>> regardless of the presence or absence of the LOCK prefix."  to XCHG
>> instructions with memory operands.  That would be easy to fix, but
>> they did not.  And Chris M. Thomasson understood it as including
>> XCHG reg, reg.
...
>Frankly, I don't understand what both you and Dan Cross are talking
>about.
>I don't see how sentence from Intel's manual ("If a memory operand is
>referenced, the processor=E2=80=99s locking protocol is automatically
>implemented for the duration of the exchange operation, regardless of
>the presence or absence of the LOCK prefix or of the value of the IOPL")
>or sentence from AMD's manual ("If either operand references memory,
>the processor locks automatically, whether or not the LOCK prefix is
>used and independently of the value of IOPL.") can be pssibly
>misunderstood.

Chris M. Thomasson wrote in <11arg45$2p70p$1@dont-email.me>:
|Well, for some reason the LOCK prefix is implied for XCHG.

Given that the thread up to that point was aboyt XCHG reg, reg (and
according to the subject it still is), he seems to be an example that
what Intel wrote about XCHG and LOCK can be misunderstood.  I looked
at the documentation and cited the relevant sentences in
<2026Oct16.075055@mips.complang.tuwien.ac.at>; most occurences clearly
refer only to XCHG where one operand is in memory.  The exception is:

|The XCHG instruction always asserts the LOCK# signal regardless of the
|presence or absence of the LOCK prefix.

And actually all the stuff about XCHG with memory operands does not
contradict this sentence.  It could be understood as meaning that
while all the other aspects of locking don't apply to "XCHG reg, reg",
the assertion of the LOCK# signal still has to occur, and that's why
Intel processors implement a slow XCHG reg, reg.  I don't think that's
what Intel intends and implements, but that's what a reading of their
manual implies.

- anton
-- 
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>
Technical Details
Message-ID: <2026Oct18.185726@mips.complang.tuwien.ac.at>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11au1vu$3ks5m$2@dont-email.me> <11aunpn$8c6$1@reader2.panix.com> <1792257076-5857@newsgrouper.org> <11b0bd3$b5b$1@reader2.panix.com> <1792265982-5857@newsgrouper.org> <2026Oct18.170823@mips.complang.tuwien.ac.at> <20261018184318.00000bee@yahoo.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Performance of xchg reg,reg
Date: Sun, 18 Oct 2026 16:57:26 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 46
Message-ID: <2026Oct18.185726@mips.complang.tuwien.ac.at>
References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11au1vu$3ks5m$2@dont-email.me> <11aunpn$8c6$1@reader2.panix.com> <1792257076-5857@newsgrouper.org> <11b0bd3$b5b$1@reader2.panix.com> <1792265982-5857@newsgrouper.org> <2026Oct18.170823@mips.complang.tuwien.ac.at> <20261018184318.00000bee@yahoo.com>
Injection-Date: Sun, 18 Oct 2026 17:13:19 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1387329"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19en2HYJBLSsYbDDyfEonjH"; posting-host="ba7b1f5472640d23e9d2e2c2f24e9c05"
Cancel-Lock: sha1:+2cLbukKeUoDlo2rc81PHOxDOmc= sha256:orWAq/oAWjToEFMV/GxHvb8QqK5TJ23pxmohoPxsOOU=
	sha1:xKjT/TJ4p4deu4vf4LfTkQyNgiE= sha256:o3OoIIqzgMRRW0tqShFyua52hv/SsFJAUWGVRSeL+Lk=
X-newsreader: xrn 10.11