6-41
INSTRUCTION SET SUMMARY
the EFLAGS register controls whether the registers are incremented (DF=0) or decremented
(DF=1). The STD and CLD instructions set and clear this flag, respectively.
The following repeat prefixes can be used in conjunction with a count in the ECX register to
cause a string instruction to repeat:
REPRepeat while the ECX register not zero.
REPE/REPZRepeat while the ECX register not zero and the ZF flag is set.
REPNE/REPNZRepeat while the ECX register not zero and the ZF flag is clear.
When a string instruction has a repeat prefix, the operation executes until one of the termination
conditions specified by the prefix is satisfied. The REPE/REPZ and REPNE/REPNZ prefixes
are used only with the CMPS and SCAS instructions. Also, note that a A REP STOS instruction
is the fastest way to initialize a large block of memory.
6.11.I/O INSTRUCTIONS
The IN (input from port to register), INS (input from port to string), OUT (output from register
to port), and OUTS (output string to port) instructions move data between the processors I/O
ports and either a register or memory.
The register I/O instructions (IN and OUT) move data between an I/O port and the EAX register
(32-bit I/O), the AX register (16-bit I/O), or the AL (8-bit I/O) register. The I/O port being read
or written to is specified with an immediate operand or an address in the DX register.
The block I/O instructions (INS and OUTS) instructions move blocks of data (strings) between
an I/O port and memory. These instructions operate similar to the string instructions (refer to
Section 6.10., String Operations). The ESI and EDI registers are used to specify string
elements in memory and the repeat prefixes (REP) are used to repeat the instructions to imple-
ment block moves. The assembler recognizes the following alternate mnemonics for these
instructions: INSB (input byte), INSW (input word), and INSD (input doubleword), and OUTB
(output byte), OUTW (output word), and OUTD (output doubleword).
The INS and OUTS instructions use an address in the DX register to specify the I/O port to be
read or written to.
6.12.ENTER AND LEAVE INSTRUCTIONS
The ENTER and LEAVE instructions provide machine-language support for procedure calls in
block-structured languages, such as C and Pascal. These instructions and the call and return
mechanism that they support are described in detail in Section 4.5., Procedure Calls for Block-
Structured Languages in Chapter 4, Procedure Calls, Interrupts, and Exceptions.