The MASM Forum

General => The Laboratory => Topic started by: jj2007 on April 22, 2022, 08:59:36 PM

Title: What are the 5 most absurd x86 assembly instructions?
Post by: jj2007 on April 22, 2022, 08:59:36 PM
Every instruction was created with a purpose, and even if the purpose is highly specialized, it's still a purpose. (https://www.quora.com/What-are-the-5-most-absurd-x86-assembly-instructions/answer/Joe-Zbiciak)

fnop, BSF, BSR, SARX/SHLX/SHRX, INTO, GF2P8AFFINEINVQB...

See here (https://alt.folklore.computers.narkive.com/tO9isa1Q/amc-proposes-1980s-computer-tv-series) for the AAC instruction (use Ctrl F to find AAC inside the page); my favourite so far is WBT :cool:
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: LiaoMi on April 23, 2022, 08:43:27 AM
 :biggrin:

nopw %cs:0L(%rax,%rax,1)
nopl 0(%rax,%rax,1)
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: hutch-- on April 23, 2022, 10:19:36 AM
 :biggrin:

I think AT&T notation GAS is more as a backend for the GNU C compiler than for writing assembler code manually. GAS with Intel notation is OK to use with a little practice.
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: _japheth on April 30, 2022, 03:32:59 AM
Quote from: jj2007 on April 22, 2022, 08:59:36 PM
fnop, BSF, BSR, SARX/SHLX/SHRX, INTO, GF2P8AFFINEINVQB...

Ouch - I admit I used SHLD and SHRD quite regularly and found them useful for 64-bit shifts. Since they are so absurd, what am I missing?  :hmmm:
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: jj2007 on April 30, 2022, 09:50:40 AM
Quote from: _japheth on April 30, 2022, 03:32:59 AM
Ouch - I admit I used SHLD and SHRD quite regularly and found them useful for 64-bit shifts. Since they are so absurd, what am I missing?  :hmmm:

I didn't mention shld or shrd, and they are not found in the pages I am linking to. Probably you confuse it with the SHLX and SHRX instructions mentioned there.

I use shld/shrd 3 times in 43k lines of code, so I agree they are not absurd - although rarely needed :cool:
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: _japheth on April 30, 2022, 10:55:24 AM
Quote from: jj2007 on April 30, 2022, 09:50:40 AM
I didn't mention shld or shrd, and they are not found in the pages I am linking to. Probably you confuse it with the SHLX and SHRX instructions mentioned there.

Ah, I see  I thought the 'X' in SHLX/SHRX was a placeholder for SHLD/SHRD/SHLQ/SHRQ/....  :tongue:
Title: Re: What are the 5 most absurd x86 assembly instructions?
Post by: jj2007 on April 30, 2022, 06:42:56 PM
SARX/SHLX/SHRX — Shift Without Affecting Flags (https://www.felixcloutier.com/x86/sarx:shlx:shrx)

On a side note (https://www.agner.org/optimize/blog/read.php?i=860&v=t): "SHL is faster if surrounded by instructions that write all flags without reading them. (This is one case where ADD 1 is preferable to INC) ... still a lot worse than SHLX"