@cindex shld, obsolete usage
@cindex shrd, obsolete usage

@c Intel mnemonics
@opindex SHL
@opindex SAL
@opindex SHR
@opindex SAR
@opindex SHLD
@opindex SHRD

@c opcode description
@opindex Shift logical left
@opindex Shift arithmetic left
@opindex Shift logical right
@opindex Shift arithmetic right
@opindex Double-precision shift left
@opindex Double-precision shift right

@c djasm mnemonics
@opindex shl
@opindex sal
@opindex shr
@opindex sar
@opindex dshl
@opindex dshr

@multitable {--------} {----------} {--------------------------------------------------}
@item Intel     @tab DJASM      @tab Meaning
@item ~~~~~~~~  @tab ~~~~~~~~~~ @tab ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@item SHL       @tab shl[bwd]   @tab Shift logical left [1]
@item SAL       @tab sal[bwd]   @tab Shift arithmetic left
@item SHR       @tab shr[bwd]   @tab Shift logical right [1]
@item SHR       @tab sar[bwd]   @tab Shift arithmetic right
@item SHLD      @tab dshl       @tab Double precision shift left [2]
@item SHRD      @tab dshr       @tab Double precision shift right [2]
@end multitable

@subsubsection Notes

@enumerate 1

@item
The mnemonics for the double-precision shifts have changed.
@xref{shxd, Change in Mnemonic Usage}, for additional information.

@item
This mnemonic does not take a @code{b}, @code{d}, or @code{w} suffix.

@end enumerate

@anchor{shxd}
@subsubheading Change in Mnemonic Usage

Beginning with the version of @code{djasm} released with DJGPP v2.04,
the mnemonics @code{shld} and @code{shrd} no longer denote Intel's
double-precision shift instructions @code{SHLD} and @code{SHRD},
respectively.
The correct mnemonics to use for the double-precision shifts are
@code{dshl} and @code{dshr}.
@c These instructions do not take a memory operand-size suffix.
Any attempt to write @code{shld} or @code{shrd} for a double-precision
shift will generate an error message and the correct mnemonic to use
(@code{dshl} or @code{dshr}) will be indicated.

If you are interested, here is the reason for the change.

The convention in @code{djasm} is to specify the memory operand size by
appending a @code{b} (byte), @code{w} (word), or @code{d} (double word)
suffix to the mnemonic.
There was one exception, however:
in the version of @code{djasm} released with DJGPP v2.03,
the mnemonics @code{shld} and @code{shrd} were used
to denote Intel's double-precision left/right shift instructions.
This usage was inconsistent with every other instruction
that could reference a byte, word, or double word memory operand
(under the existing convention these mnemonics would be expected
to denote left and right shifts of a double-word memory operand).
However, the double-precision shifts had been implemented @emph{before}
support was added for basic shifts of memory operands (at the time, only
basic shifts of register operands had been implemented).

The cleanest solution was to replace the mnemonics used by @code{djasm}
for the double-precision shift instructions and reserve @code{shld} and
@code{shrd} for basic shifts of a double-word memory operand.
At the time this change was made (between v2.03 and 2.04) there
were no @file{*.asm} files in the DJGPP @acronym{CVS} tree that used
@code{shld} or @code{shrd}.

It is possible that someone, somewhere, used @code{shld} or @code{shrd}
to code for a double-precision shift, but this seems unlikely.
According to the DJGPP mail archives, these instructions were added by
@email{bill@@taniwha.org,Bill Currie}, who soon thereafter recognized
the impending conflict and redefined the mnemonics in his own version
of @code{djasm}.
Unfortunately, his changes did not make it into the stock @file{djasm.y}
at that time.
Furthermore, documentation for @code{djasm} has been minimal, and the
only way to know what instructions were supported (and what the mnemonics
were) was to inspect @file{djasm.y}, or to inspect source code (such as
@file{stub.asm}) for @code{djasm} applications.
