* better
[mascara-docs.git] / hw / i386.reference / LODS.htm
blob742247e6ccaa50a9952620a038f6477c2fca4a0f
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Opcode LODS</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="LOCK.htm"> LOCK Assert LOCK# Signal Prefix</A><BR>
10 <B>next:</B><A HREF="LOOP.htm"> LOOP/LOOPcond Loop Control with CX Counter</A>
11 <P>
12 <HR>
13 <P>
14 <H1>LODS/LODSB/LODSW/LODSD -- Load String Operand</H1>
16 <PRE>
17 Opcode Instruction Clocks Description
19 AC LODS m8 5 Load byte [(E)SI] into AL
20 AD LODS m16 5 Load word [(E)SI] into AX
21 AD LODS m32 5 Load dword [(E)SI] into EAX
22 AC LODSB 5 Load byte DS:[(E)SI] into AL
23 AD LODSW 5 Load word DS:[(E)SI] into AX
24 AD LODSD 5 Load dword DS:[(E)SI] into EAX
25 </PRE>
27 <H2>Operation</H2>
29 <PRE>
30 IF AddressSize = 16
31 THEN use SI for source-index
32 ELSE (* AddressSize = 32 *)
33 use ESI for source-index;
34 FI;
35 IF byte type of instruction
36 THEN
37 AL := [source-index]; (* byte load *)
38 IF DF = 0 THEN IncDec := 1 ELSE IncDec := -1; FI;
39 ELSE
40 IF OperandSize = 16
41 THEN
42 AX := [source-index]; (* word load *)
43 IF DF = 0 THEN IncDec := 2 ELSE IncDec := -2; FI;
44 ELSE (* OperandSize = 32 *)
45 EAX := [source-index]; (* dword load *)
46 IF DF = 0 THEN IncDec := 4 ELSE IncDec := -4; FI;
47 FI;
48 FI;
49 source-index := source-index + IncDec
50 </PRE>
52 <H2>Description</H2>
54 LODS loads the AL, AX, or EAX register with the memory byte, word,
55 or doubleword at the location pointed to by the source-index register.
56 After the transfer is made, the source-index register is automatically
57 advanced. If the direction flag is 0 (<A HREF="CLD.htm">CLD</A> was executed), the source index
58 increments; if the direction flag is 1 (<A HREF="STD.htm">STD</A> was executed), it decrements.
59 The increment or decrement is 1 if a byte is loaded, 2 if a word is loaded,
60 or 4 if a doubleword is loaded.
61 <P>
62 If the address-size attribute for this instruction is 16 bits, SI is used
63 for the source-index register; otherwise the address-size attribute is 32
64 bits, and the ESI register is used. The address of the source data is
65 determined solely by the contents of ESI/SI. Load the correct index value
66 into SI before executing the LODS instruction. LODSB, LODSW, LODSD are
67 synonyms for the byte, word, and doubleword LODS instructions.
68 <P>
69 LODS can be preceded by the
70 <A HREF="REP.htm">REP</A> prefix; however, LODS is used more typically
71 within a
72 <A HREF="LOOP.htm">LOOP</A> construct,
73 because further processing of the data moved into
74 EAX, AX, or AL is usually necessary.
76 <H2>Flags Affected</H2>
78 None
80 <H2>Protected Mode Exceptions</H2>
82 #GP(0) for an illegal memory operand effective address in the CS, DS,
83 ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment;
84 #PF(fault-code) for a page fault
86 <H2>Real Address Mode Exceptions</H2>
88 Interrupt 13 if any part of the operand would lie outside of the effective
89 address space from 0 to 0FFFFH
91 <H2>Virtual 8086 Mode Exceptions</H2>
93 Same exceptions as in Real Address Mode; #PF(fault-code) for a page
94 fault
97 <P>
98 <HR>
99 <P>
100 <B>up:</B> <A HREF="c17.htm">
101 Chapter 17 -- 80386 Instruction Set</A><BR>
102 <B>prev:</B><A HREF="LOCK.htm"> LOCK Assert LOCK# Signal Prefix</A><BR>
103 <B>next:</B><A HREF="LOOP.htm"> LOOP/LOOPcond Loop Control with CX Counter</A>
104 </BODY>