Comment by peterfirefly

15 hours ago

> There are edge cases in x86

Some early 386 CPUs had XBTS/IBTS instructions (extract/insert bit string). They used 0F A6 and 0F A7 encodings.

Some early 486 CPUs had CMPXCHG encodings that reused the XBTS/IBTS encodings. That apparently screwed up some programs that tried to execute XBTS/IBTS to see if they were running on early (buggy) 386s so Intel moved CMPXCHG to different encodings (0F B0 and 0F B1).

0F A6 and 0F A7 are still left unused by Intel and AMD in their modern chips.

There's also the delightfully petty story about SYSENTER/SYSEXIT and SYSCALL/SYSRET for fast system calls. Intel came up with the first pair, AMD with the second. AMD of course had to support both and operating systems generally only supported Intel's pair.

Then AMD extended the x86 to 64 bits and of course required SYSCALL/SYSRET for 64-bit system calls (and did not support SYSENTER/SYSEXIT in 64-bit mode). Intel had to support AMD's instructions in 64-bit mode but decided to also support SYSENTER/SYSEXIT there (which I don't think any operating system has ever bothered to support).

To summarize: AMD supports both methods outside of 64-bit mode and only their own in 64-bit mode. Intel supports both methods in 64-bit mode and only their own in 32-bit mode. Or at least that's how it used to be. Maybe they've mellowed out by now.

Oh I remember SYSENTER/SYSEXIT, I think. I worked on CTOS, widely released by Burroughs/Unisys back then. CTOS used all the clever instructions. They performed badly. Later I learned from an Intel customer consultant on porting code, that we were the only ones who ever embraced fancy things like task gates etc. Everybody else just continued using regular push/pop and simple traps. Because they ran faster.