* better
[mascara-docs.git] / hw / i386.reference / s16_02.htm
blob7b48c23dfa82afaa72edb967cb70d8cab08400cf
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Section 16.2</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c16.htm">
8 Chapter 16 -- Mixing 16-Bit and 32 Bit Code</A><BR>
9 <B>prev:</B> <A HREF="s16_01.htm">16.1 How the 80386 Implements 16-Bit and 32-Bit Features</A><BR>
10 <B>next:</B> <A HREF="s16_03.htm">16.3 Sharing Data Segments Among Mixed Code Segments</A>
11 <P>
12 <HR>
13 <P>
14 <H1>16.2 Mixing 32-Bit and 16-Bit Operations</H1>
15 The 80386 has two instruction prefixes that allow mixing of 32-bit and
16 16-bit operations within one segment:
17 <UL>
18 <LI> The operand-size prefix (66H)
19 <LI> The address-size prefix (67H)
20 </UL>
21 <P>
22 These prefixes reverse the default size selected by the D-bit. For example,
23 the processor can interpret the word-move instruction <A HREF="MOV.htm">MOV</A> mem, reg in any of
24 four ways:
25 <UL>
26 <LI> In a USE32 segment:
27 <OL>
28 <LI> Normally moves 32 bits from a 32-bit register to a 32-bit
29 effective address in memory.
30 <LI> If preceded by an operand-size prefix, moves 16 bits from a 16-bit
31 register to 32-bit effective address in memory.
32 <LI> If preceded by an address-size prefix, moves 32 bits from a 32-bit
33 register to a16-bit effective address in memory.
34 <LI> If preceded by both an address-size prefix and an operand-size
35 prefix, moves 16 bits from a 16-bit register to a 16-bit effective
36 address in memory.
37 </OL>
38 <LI> In a USE16 segment:
39 <OL>
40 <LI> Normally moves 16 bits from a 16-bit register to a 16-bit
41 effective address in memory.
42 <LI> If preceded by an operand-size prefix, moves 32 bits from a 32-bit
43 register to 16-bit effective address in memory.
44 <LI> If preceded by an address-size prefix, moves 16 bits from a 16-bit
45 register to a32-bit effective address in memory.
46 <LI> If preceded by both an address-size prefix and an operand-size
47 prefix, moves 32 bits from a 32-bit register to a 32-bit effective
48 address in memory.
49 </OL>
50 </UL>
51 These examples illustrate that any instruction can generate any combination
52 of operand size and address size regardless of whether the instruction is in
53 a USE16 or USE32 segment. The choice of the USE16 or USE32 attribute for a
54 code segment is based upon these criteria:
55 <OL>
56 <LI> The need to address instructions or data in segments that are larger
57 than 64 Kilobytes.
58 <LI> The predominant size of operands.
59 <LI> The addressing modes desired. (Refer to
60 <A HREF="c17.htm">Chapter 17</A> for an explanation
61 of the additional addressing modes that are available when 32-bit
62 addressing is used.)
63 </OL>
64 Choosing a setting of the D-bit that is contrary to the predominant size of
65 operands requires the generation of an excessive number of operand-size
66 prefixes.
67 <P>
68 <HR>
69 <P>
70 <B>up:</B> <A HREF="c16.htm">
71 Chapter 16 -- Mixing 16-Bit and 32 Bit Code</A><BR>
72 <B>prev:</B> <A HREF="s16_01.htm">16.1 How the 80386 Implements 16-Bit and 32-Bit Features</A><BR>
73 <B>next:</B> <A HREF="s16_03.htm">16.3 Sharing Data Segments Among Mixed Code Segments</A>
74 </BODY>