* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / INS.htm
blob7c3254095bc380b5bd2cca9d50f8e556c21f8a3f
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode INS</TITLE>
5 </HEAD>
6 <BODY>
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>
11 <P>
12 <HR>
13 <P>
14 <H1>INS/INSB/INSW/INSD -- Input from Port to String</H1>
16 <PRE>
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
25 </PRE>
27 <EM>
28 <H3>Notes</H3>
29 <PRE>
30 *If CPL <= IOPL
31 **If CPL > IOPL or if in virtual 8086 mode
32 </PRE>
33 </EM>
35 <H2>Operation</H2>
37 <PRE>
38 IF AddressSize = 16
39 THEN use DI for dest-index;
40 ELSE (* AddressSize = 32 *)
41 use EDI for dest-index;
42 FI;
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))
46 THEN #GP(0);
47 FI;
48 FI;
49 IF byte type of instruction
50 THEN
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;
53 FI;
54 IF OperandSize = 16
55 THEN
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;
58 FI;
59 IF OperandSize = 32
60 THEN
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;
63 FI;
64 dest-index := dest-index + IncDec;
65 </PRE>
67 <H2>Description</H2>
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.
74 <P>
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.
78 <P>
79 The destination address is determined by the contents of the destination
80 index register. Load the correct index into the destination index register
81 before executing INS.
82 <P>
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.
88 <P>
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
94 operation.
96 <H2>Flags Affected</H2>
98 None
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
120 <HR>
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>
126 </BODY>