* remove "\r" nonsense
[mascara-docs.git] / i386 / i386.reference / s02_02.htm
blobbe975f83ec0486f912349d58a9ad372da50a5013
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Section 2.2</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c02.htm">
8 Chapter 2 -- Basic Programming Model</A><BR>
9 <B>prev:</B> <A HREF="s02_01.htm">2.1 Memory Organization and Segmentation</A><BR>
10 <B>next:</B> <A HREF="s02_03.htm">2.3 Registers</A>
11 <P>
12 <HR>
13 <P>
14 <H1>2.2 Data Types</H1>
15 Bytes, words, and doublewords are the fundamental data types (refer to
17 <A HREF="#fig2-2">Figure 2-2</A>
18 ). A byte is eight contiguous bits starting at any logical
19 address. The bits are numbered 0 through 7; bit zero is the least
20 significant bit.
21 <P>
22 A word is two contiguous bytes starting at any byte address. A word thus
23 contains 16 bits. The bits of a word are numbered from 0 through 15; bit 0
24 is the least significant bit. The byte containing bit 0 of the word is
25 called the low byte; the byte containing bit 15 is called the high byte.
26 <P>
27 Each byte within a word has its own address, and the smaller of the
28 addresses is the address of the word. The byte at this lower address
29 contains the eight least significant bits of the word, while the byte at the
30 higher address contains the eight most significant bits.
31 <P>
32 A doubleword is two contiguous words starting at any byte address. A
33 doubleword thus contains 32 bits. The bits of a doubleword are numbered from
34 0 through 31; bit 0 is the least significant bit. The word containing bit 0
35 of the doubleword is called the low word; the word containing bit 31 is
36 called the high word.
37 <P>
38 Each byte within a doubleword has its own address, and the smallest of the
39 addresses is the address of the doubleword. The byte at this lowest address
40 contains the eight least significant bits of the doubleword, while the byte
41 at the highest address contains the eight most significant bits.
42 <A HREF="#fig2-3">Figure 2-3</A>
44 illustrates the arrangement of bytes within words anddoublewords.
45 <P>
46 Note that words need not be aligned at even-numbered addresses and
47 doublewords need not be aligned at addresses evenly divisible by four. This
48 allows maximum flexibility in data structures (e.g., records containing
49 mixed byte, word, and doubleword items) and efficiency in memory
50 utilization. When used in a configuration with a 32-bit bus, actual
51 transfers of data between processor and memory take place in units of
52 doublewords beginning at addresses evenly divisible by four; however, the
53 processor converts requests for misaligned words or doublewords into the
54 appropriate sequences of requests acceptable to the memory interface. Such
55 misaligned data transfers reduce performance by requiring extra memory
56 cycles. For maximum performance, data structures (including stacks) should
57 be designed in such a way that, whenever possible, word operands are aligned
58 at even addresses and doubleword operands are aligned at addresses evenly
59 divisible by four. Due to instruction prefetching and queuing within the
60 CPU, there is no requirement for instructions to be aligned on word or
61 doubleword boundaries. (However, a slight increase in speed results if the
62 target addresses of control transfers are evenly divisible by four.)
63 <P>
64 Although bytes, words, and doublewords are the fundamental types of
65 operands, the processor also supports additional interpretations of these
66 operands. Depending on the instruction referring to the operand, the
67 following additional data types are recognized:
68 <DL>
69 <DT>
70 Integer:
71 <DD>
72 A signed binary numeric value contained in a 32-bit doubleword, 16-bit word,
73 or 8-bit byte. All operations assume a 2's complement representation. The
74 sign bit is located in bit 7 in a byte, bit 15 in a word, and bit 31 in a
75 doubleword. The sign bit has the value zero for positive integers and one
76 for negative. Since the high-order bit is used for a sign, the range of an
77 8-bit integer is -128 through +127; 16-bit integers may range from -32,768
78 through +32,767; 32-bit integers may range from -2^(31) through +2^(31) -1.
79 The value zero has a positive sign.
80 <DT>
81 Ordinal:
82 <DD>
83 An unsigned binary numeric value contained in a 32-bit doubleword,
84 16-bit word, or 8-bit byte. All bits are considered in determining
85 magnitude of the number. The value range of an 8-bit ordinal number
86 is 0-255; 16 bits can represent values from 0 through 65,535; 32 bits
87 can represent values from 0 through 2^(32) -1.
88 <DT>
89 Near Pointer:
90 <DD>
91 A 32-bit logical address. A near pointer is an offset within a segment.
92 Near pointers are used in either a flat or a segmented model of memory
93 organization.
94 <DT>
95 Far Pointer:
96 <DD>
97 A 48-bit logical address of two components: a 16-bit segment selector
98 component and a 32-bit offset component. Far pointers are used by
99 applications programmers only when systems designers choose a
100 segmented memory organization.
101 <DT>
102 String:
103 <DD>
104 A contiguous sequence of bytes, words, or doublewords. A string may
105 contain from zero bytes to 2^(32) -1 bytes (4 gigabytes).
106 <DT>
107 Bit field:
108 <DD>
109 A contiguous sequence of bits. A bit field may begin at any bit position
110 of any byte and may contain up to 32 bits.
111 <DT>
112 Bit string:
113 <DD>
114 A contiguous sequence of bits. A bit string may begin at any bit position
115 of any byte and may contain up to 2^(32) -1 bits.
116 <DT>
117 BCD:
118 <DD>
119 A byte (unpacked) representation of a decimal digit in the range 0 through 9.
120 Unpacked decimal numbers are stored as unsigned byte quantities. One
121 digit is stored in each byte. The magnitude of the number is determined from
122 the low-order half-byte; hexadecimal values 0-9 are valid and are
123 interpreted as decimal numbers. The high-order half-byte must be zero for
124 multiplication and division; it may contain any value for addition and
125 subtraction.
126 <DT>
127 Packed BCD:
128 <DD>
129 A byte (packed) representation of two decimal digits, each in the range
130 0 through 9. One digit is stored in each half-byte. The digit in the
131 high-order half-byte is the most significant. Values 0-9 are valid in each
132 half-byte. The range of a packed decimal byte is 0-99.
133 </DL>
135 <A HREF="#fig2-4">Figure 2-4</A>
136 graphically summarizes the data types supported by the 80386.
138 <A NAME="fig2-1">
139 <IMG align=center SRC="fig2-1.gif" border=0>
141 <HR>
143 <A NAME="fig2-2">
144 <IMG align=center SRC="fig2-2.gif" border=0>
146 <HR>
148 <A NAME="fig2-3">
149 <IMG align=center SRC="fig2-3.gif" border=0>
151 <HR>
153 <A NAME="fig2-4">
154 <IMG align=center SRC="fig2-4.gif" border=0>
156 <HR>
158 <B>up:</B> <A HREF="c02.htm">
159 Chapter 2 -- Basic Programming Model</A><BR>
160 <B>prev:</B> <A HREF="s02_01.htm">2.1 Memory Organization and Segmentation</A><BR>
161 <B>next:</B> <A HREF="s02_03.htm">2.3 Registers</A>
162 </BODY>