1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
4 <TITLE>80386 Programmer's Reference Manual -- Opcode INS
</TITLE>
7 <B>up:
</B> <A HREF=
"c17.htm">
8 Chapter
17 --
80386 Instruction Set
</A><BR>
9 <B>prev:
</B><A HREF=
"INC.htm"> INC Increment by
1</A><BR>
10 <B>next:
</B><A HREF=
"INT.htm"> INT/INTO Call to Interrupt Procedure
</A>
14 <H1>INS/INSB/INSW/INSD -- Input from Port to String
</H1>
17 Opcode Instruction Clocks Description
19 6C INS r/m8,DX
15,pm=
9*/
29** Input byte from port DX into ES:(E)DI
20 6D INS r/m16,DX
15,pm=
9*/
29** Input word from port DX into ES:(E)DI
21 6D INS r/m32,DX
15,pm=
9*/
29** Input dword from port DX into ES:(E)DI
22 6C INSB
15,pm=
9*/
29** Input byte from port DX into ES:(E)DI
23 6D INSW
15,pm=
9*/
29** Input word from port DX into ES:(E)DI
24 6D INSD
15,pm=
9*/
29** Input dword from port DX into ES:(E)DI
31 **If CPL
> IOPL or if in virtual
8086 mode
39 THEN use DI for dest-index;
40 ELSE (* AddressSize =
32 *)
41 use EDI for dest-index;
43 IF (PE =
1) AND ((VM =
1) OR (CPL
> IOPL))
44 THEN (* Virtual
8086 mode, or protected mode with CPL
> IOPL *)
45 IF NOT I-O-Permission (SRC, width(SRC))
49 IF byte type of instruction
51 ES:[dest-index] := [DX]; (* Reads byte at DX from I/O address space *)
52 IF DF =
0 THEN IncDec :=
1 ELSE IncDec := -
1; FI;
56 ES:[dest-index] := [DX]; (* Reads word at DX from I/O address space *)
57 IF DF =
0 THEN IncDec :=
2 ELSE IncDec := -
2; FI;
61 ES:[dest-index] := [DX]; (* Reads dword at DX from I/O address space *)
62 IF DF =
0 THEN IncDec :=
4 ELSE IncDec := -
4; FI;
64 dest-index := dest-index + IncDec;
69 INS transfers data from the input port numbered by the DX register to
70 the memory byte or word at ES:dest-index. The memory operand must
71 be addressable from ES; no segment override is possible. The destination
72 register is DI if the address-size attribute of the instruction is
16 bits,
73 or EDI if the address-size attribute is
32 bits.
75 INS does not allow the specification of the port number as an immediate
76 value. The port must be addressed through the DX register value. Load
77 the correct value into DX before executing the INS instruction.
79 The destination address is determined by the contents of the destination
80 index register. Load the correct index into the destination index register
83 After the transfer is made, DI or EDI advances automatically. If the
84 direction flag is
0 (CLD was executed), DI or EDI increments; if the
85 direction flag is
1 (STD was executed), DI or EDI decrements. DI
86 increments or decrements by
1 if a byte is input, by
2 if a word is input,
87 or by
4 if a doubleword is input.
89 INSB, INSW and INSD are synonyms of the byte, word, and doubleword
90 INS instructions. INS can be preceded by the
91 <A HREF=
"REP.htm">REP
</A> prefix for block input of
92 CX bytes or words. Refer to the
93 <A HREF=
"REP.htm">REP
</A> instruction for details of this
96 <H2>Flags Affected
</H2>
100 <H2>Protected Mode Exceptions
</H2>
102 #GP(
0) if CPL is numerically greater than IOPL and any of the
103 corresponding I/O permission bits in TSS equals
1; #GP(
0) if the
104 destination is in a nonwritable segment; #GP(
0) for an illegal memory
105 operand effective address in the CS, DS, ES, FS, or GS segments; #SS(
0) for
106 an illegal address in the SS segment; #PF(fault-code) for a page fault
108 <H2>Real Address Mode Exceptions
</H2>
110 Interrupt
13 if any part of the operand would lie outside of the effective
111 address space from
0 to
0FFFFH
113 <H2>Virtual
8086 Mode Exceptions
</H2>
115 #GP(
0) fault if any of the corresponding I/O permission bits in TSS
116 equals
1; #PF(fault-code) for a page fault
122 <B>up:
</B> <A HREF=
"c17.htm">
123 Chapter
17 --
80386 Instruction Set
</A><BR>
124 <B>prev:
</B><A HREF=
"INC.htm"> INC Increment by
1</A><BR>
125 <B>next:
</B><A HREF=
"INT.htm"> INT/INTO Call to Interrupt Procedure
</A>