-
String Operations.
-
MOVS
,
LODS
,
STOS
,
INS
,
OUTS
-
Allow data transfers of a byte, a word or a double word, or if repeated, a block of each of these.
-
The
D
flag-bit (direction),
SI
and
DI
are implicitly used.
-
D = 0
: Autoincrement
DI
and
SI
.
-
Use
CLD
instruction to clear this flag.
-
D = 1
: Autodecrement
DI
and
SI
.
-
Use
STD
instruction to set it.
-
DI
:
-
Accesses data in the extra segment. Can NOT override.
-
SI
:
-
Accesses data in the data segment. Can be overridden with segment override prefix.
-
String Operations.
-
LODS
:
-
Loads
AL
,
AX
or
EAX
with data stored at the data segment (or extra segment) + offset given by
SI
.
-
SI
is incremented or decremented afterwards:
-
STOSB
:
-
Stores
AL
,
AX
or
EAX
to the extra segment (ES) + offset given by
DI
. ES cannot be overridden.
-
DI
is incremented or decremented afterwards:
-
String Operations.
-
REP
prefix:
-
Executes the instruction
CX
times.
-
NOTE:
REP
does not make sense with the
LODS
instruction.
-
String Operations.
-
MOVS
:
-
Moves a byte, word or doubleword from data segment and offset
SI
to extra segment and offset
DI
.
-
Increments/decrements both
DI
and
SI
:
-
INS/OUTS
(not available on the 8086):
-
Transfers a byte, word or doubleword of data from/to an I/O device into/outof the extra/data segment + offset
DI
/
SI
, respectively.
-
The I/O address is stored in the
DX
register.
-
NOTE:
-
This assumes the device is able to make data available at the speed of the program, and in sync with the program.
-
Since this is almost never true, the code above needs to have a "device status check" instruction(s).
-
Of course, the
REP
prefix can not be used in this case.
-
The same holds true for
OUTS
instructions.
-
Miscellaneous Data Transfer Operations.
-
XCHG
:
-
Exchanges the contents of a register with the contents of any other register or memory location.
-
It can NOT exchange segment registers or memory-to-memory data.
-
Byte, word and doublewords can be exchanged using any addressing mode (except immediate, of course).
-
XLAT
:
-
Performs a table lookup operation by converting the value in
AL
from an index to a value stored in the cell of a table in memory.
-
Miscellaneous Data Transfer Operations.
-
IN
and
OUT
:
-
Transfers a byte, word or doubleword of data from/to an I/O device into/outof
AL
,
AX
and
EAX
, respectively.
-
Memory operations are not available (as they are in
INS
and
OUTS
):
-
Fixed-port addressing:
-
8-bit
port number encoded in instruction.
-
8-bit
value is sign-extended into address bits
8-15
.
-
Address bits
16-31
are undefined.
-
Variable-port addressing:
-
16-bit
port number stored in
DX
.
-
Miscellaneous Data Transfer Operations.
-
Note that the old contents of the higher-order bit positions of the port are preserved.
-
Miscellaneous Data Transfer Operations.
-
MOVSX
and
MOVZX
(80386 and up only):
-
Move-and-sign-extend and Move-and-zero-extend:
-
BSWAP
(80486 and up only):
-
Swaps the first byte with the forth, and the second byte with the third.
-
Used to convert between little endian and big endian:
-
Miscellaneous Data Transfer Operations.
-
CMOV
(Pentium and up only):
-
These instructions move data only if a condition is true.
-
Conditions are set by a previous instruction and include
Carry
,
Zero
,
Sign
,
Overflow
and
Parity
:
-
There are many variations of this instruction.
-
See Appendix B of text.
-
Segment Override Prefix:
-
Allows the programmer to override the default segment.
-
Appends an additional byte to the front of an instruction.
-
Jump and Call instructions cannot be prefixed, must use CS.
-
Full Segment Definitions: