Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/yasm/patched-yasm/yasm_arch.7

Issue 11365061: Update Yasm to 1.2.0 (Yasm Part 3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/yasm/patched-yasm/po/yasm.pot ('k') | third_party/yasm/patched-yasm/yasm_parsers.7 » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 '\" t
1 .\" Title: yasm_arch 2 .\" Title: yasm_arch
2 .\" Author: Peter Johnson <peter@tortall.net> 3 .\" Author: Peter Johnson <peter@tortall.net>
3 .\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/> 4 .\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
4 .\" Date: October 2006 5 .\" Date: October 2006
5 .\" Manual: Yasm Supported Architectures 6 .\" Manual: Yasm Supported Architectures
6 .\" Source: Yasm 7 .\" Source: Yasm
8 .\" Language: English
7 .\" 9 .\"
8 .TH "YASM_ARCH" "7" "October 2006" "Yasm" "Yasm Supported Architectures" 10 .TH "YASM_ARCH" "7" "October 2006" "Yasm" "Yasm Supported Architectures"
11 .\" -----------------------------------------------------------------
12 .\" * set default formatting
13 .\" -----------------------------------------------------------------
9 .\" disable hyphenation 14 .\" disable hyphenation
10 .nh 15 .nh
11 .\" disable justification (adjust text to left margin only) 16 .\" disable justification (adjust text to left margin only)
12 .ad l 17 .ad l
18 .\" -----------------------------------------------------------------
19 .\" * MAIN CONTENT STARTS HERE *
20 .\" -----------------------------------------------------------------
13 .SH "NAME" 21 .SH "NAME"
14 yasm_arch \- Yasm Supported Target Architectures 22 yasm_arch \- Yasm Supported Target Architectures
15 .SH "SYNOPSIS" 23 .SH "SYNOPSIS"
16 .HP 5 24 .HP \w'\fByasm\fR\ 'u
17 \fByasm\fR \fB\-a\ \fR\fB\fIarch\fR\fR [\fB\-m\ \fR\fB\fImachine\fR\fR] \fB\fI.. .\fR\fR 25 \fByasm\fR \fB\-a\ \fR\fB\fIarch\fR\fR [\fB\-m\ \fR\fB\fImachine\fR\fR] \fB\fI\& .\&.\&.\fR\fR
18 .SH "DESCRIPTION" 26 .SH "DESCRIPTION"
19 .PP 27 .PP
20 The standard Yasm distribution includes a number of modules for different target architectures. Each target architecture can support one or more machine archite ctures. 28 The standard Yasm distribution includes a number of modules for different target architectures\&. Each target architecture can support one or more machine archi tectures\&.
21 .PP 29 .PP
22 The architecture and machine are selected on the 30 The architecture and machine are selected on the
23 \fByasm\fR(1) 31 \fByasm\fR(1)
24 command line by use of the 32 command line by use of the
25 \fB\-a \fR\fB\fIarch\fR\fR 33 \fB\-a \fR\fB\fIarch\fR\fR
26 and 34 and
27 \fB\-m \fR\fB\fImachine\fR\fR 35 \fB\-m \fR\fB\fImachine\fR\fR
28 command line options, respectively. 36 command line options, respectively\&.
29 .PP 37 .PP
30 The machine architecture may also automatically be selected by certain object fo rmats. For example, the 38 The machine architecture may also automatically be selected by certain object fo rmats\&. For example, the
31 \(lqelf32\(rq 39 \(lqelf32\(rq
32 object format selects the 40 object format selects the
33 \(lqx86\(rq 41 \(lqx86\(rq
34 machine architecture by default, while the 42 machine architecture by default, while the
35 \(lqelf64\(rq 43 \(lqelf64\(rq
36 object format selects the 44 object format selects the
37 \(lqamd64\(rq 45 \(lqamd64\(rq
38 machine architecture by default. 46 machine architecture by default\&.
39 .SH "X86 ARCHITECTURE" 47 .SH "X86 ARCHITECTURE"
40 .PP 48 .PP
41 The 49 The
42 \(lqx86\(rq 50 \(lqx86\(rq
43 architecture supports the IA\-32 instruction set and derivatives and the AMD64 i nstruction set. It consists of two machines: 51 architecture supports the IA\-32 instruction set and derivatives and the AMD64 i nstruction set\&. It consists of two machines:
44 \(lqx86\(rq 52 \(lqx86\(rq
45 (for the IA\-32 and derivatives) and 53 (for the IA\-32 and derivatives) and
46 \(lqamd64\(rq 54 \(lqamd64\(rq
47 (for the AMD64 and derivatives). The default machine for the 55 (for the AMD64 and derivatives)\&. The default machine for the
48 \(lqx86\(rq 56 \(lqx86\(rq
49 architecture is the 57 architecture is the
50 \(lqx86\(rq 58 \(lqx86\(rq
51 machine. 59 machine\&.
52 .SS "BITS Setting" 60 .SS "BITS Setting"
53 .PP 61 .PP
54 The x86 architecture BITS setting specifies to Yasm the processor mode in which the generated code is intended to execute. x86 processors can run in three diffe rent major execution modes: 16\-bit, 32\-bit, and on AMD64\-supporting processor s, 64\-bit. As the x86 instruction set contains portions whose function is execu tion\-mode dependent (such as operand\-size and address\-size override prefixes) , Yasm cannot assemble x86 instructions correctly unless it is told by the user in what processor mode the code will execute. 62 The x86 architecture BITS setting specifies to Yasm the processor mode in which the generated code is intended to execute\&. x86 processors can run in three dif ferent major execution modes: 16\-bit, 32\-bit, and on AMD64\-supporting process ors, 64\-bit\&. As the x86 instruction set contains portions whose function is e xecution\-mode dependent (such as operand\-size and address\-size override prefi xes), Yasm cannot assemble x86 instructions correctly unless it is told by the u ser in what processor mode the code will execute\&.
55 .PP 63 .PP
56 The BITS setting can be changed in a variety of ways. When using the NASM\-compa tible parser, the BITS setting can be changed directly via the use of the 64 The BITS setting can be changed in a variety of ways\&. When using the NASM\-com patible parser, the BITS setting can be changed directly via the use of the
57 \fBBITS xx\fR 65 \fBBITS xx\fR
58 assembler directive. The default BITS setting is determined by the object format in use. 66 assembler directive\&. The default BITS setting is determined by the object form at in use\&.
59 .SS "BITS 64 Extensions" 67 .SS "BITS 64 Extensions"
60 .PP 68 .PP
61 The AMD64 architecture is a new 64\-bit architecture developed by AMD, based on the 32\-bit x86 architecture. It extends the original x86 architecture by doubli ng the number of general purpose and SIMD registers, extending the arithmetic op erations and address space to 64 bits, as well as other features. 69 The AMD64 architecture is a new 64\-bit architecture developed by AMD, based on the 32\-bit x86 architecture\&. It extends the original x86 architecture by doub ling the number of general purpose and SIMD registers, extending the arithmetic operations and address space to 64 bits, as well as other features\&.
62 .PP 70 .PP
63 Recently, Intel has introduced an essentially identical version of AMD64 called EM64T. 71 Recently, Intel has introduced an essentially identical version of AMD64 called EM64T\&.
64 .PP 72 .PP
65 When an AMD64\-supporting processor is executing in 64\-bit mode, a number of ad ditional extensions are available, including extra general purpose registers, ex tra SSE2 registers, and RIP\-relative addressing. 73 When an AMD64\-supporting processor is executing in 64\-bit mode, a number of ad ditional extensions are available, including extra general purpose registers, ex tra SSE2 registers, and RIP\-relative addressing\&.
66 .PP 74 .PP
67 Yasm extends the base NASM syntax to support AMD64 as follows. To enable assembl y of instructions for the 64\-bit mode of AMD64 processors, use the directive 75 Yasm extends the base NASM syntax to support AMD64 as follows\&. To enable assem bly of instructions for the 64\-bit mode of AMD64 processors, use the directive
68 \fBBITS 64\fR. As with NASM's BITS directive, this does not change the format of the output object file to 64 bits; it only changes the assembler mode to assume that the instructions being assembled will be run in 64\-bit mode. To specify a n AMD64 object file, use 76 \fBBITS 64\fR\&. As with NASM\'s BITS directive, this does not change the format of the output object file to 64 bits; it only changes the assembler mode to ass ume that the instructions being assembled will be run in 64\-bit mode\&. To spec ify an AMD64 object file, use
69 \fB\-m amd64\fR 77 \fB\-m amd64\fR
70 on the Yasm command line, or explicitly target a 64\-bit object format such as 78 on the Yasm command line, or explicitly target a 64\-bit object format such as
71 \fB\-f win64\fR 79 \fB\-f win64\fR
72 or 80 or
73 \fB\-f elf64\fR. 81 \fB\-f elf64\fR\&.
74 .sp 82 .sp
75 .it 1 an-trap 83 .it 1 an-trap
76 .nr an-no-space-flag 1 84 .nr an-no-space-flag 1
77 .nr an-break-flag 1 85 .nr an-break-flag 1
78 .br 86 .br
87 .ps +1
79 \fBRegister Changes\fR 88 \fBRegister Changes\fR
80 .RS 89 .RS 4
81 .PP 90 .PP
82 The additional 64\-bit general purpose registers are named r8\-r15. There are al so 8\-bit (rXb), 16\-bit (rXw), and 32\-bit (rXd) subregisters that map to the l east significant 8, 16, or 32 bits of the 64\-bit register. The original 8 gener al purpose registers have also been extended to 64\-bits: eax, edx, ecx, ebx, es i, edi, esp, and ebp have new 64\-bit versions called rax, rdx, rcx, rbx, rsi, r di, rsp, and rbp respectively. The old 32\-bit registers map to the least signif icant bits of the new 64\-bit registers. 91 The additional 64\-bit general purpose registers are named r8\-r15\&. There are also 8\-bit (rXb), 16\-bit (rXw), and 32\-bit (rXd) subregisters that map to the least significant 8, 16, or 32 bits of the 64\-bit register\&. The original 8 g eneral purpose registers have also been extended to 64\-bits: eax, edx, ecx, ebx , esi, edi, esp, and ebp have new 64\-bit versions called rax, rdx, rcx, rbx, rs i, rdi, rsp, and rbp respectively\&. The old 32\-bit registers map to the least significant bits of the new 64\-bit registers\&.
83 .PP 92 .PP
84 New 8\-bit registers are also available that map to the 8 least significant bits of rsi, rdi, rsp, and rbp. These are called sil, dil, spl, and bpl respectively . Unfortunately, due to the way instructions are encoded, these new 8\-bit regis ters are encoded the same as the old 8\-bit registers ah, dh, ch, and bh. The pr ocessor tells which is being used by the presence of the new REX prefix that is used to specify the other extended registers. This means it is illegal to mix th e use of ah, dh, ch, and bh with an instruction that requires the REX prefix for other reasons. For instance: 93 New 8\-bit registers are also available that map to the 8 least significant bits of rsi, rdi, rsp, and rbp\&. These are called sil, dil, spl, and bpl respective ly\&. Unfortunately, due to the way instructions are encoded, these new 8\-bit r egisters are encoded the same as the old 8\-bit registers ah, dh, ch, and bh\&. The processor tells which is being used by the presence of the new REX prefix th at is used to specify the other extended registers\&. This means it is illegal t o mix the use of ah, dh, ch, and bh with an instruction that requires the REX pr efix for other reasons\&. For instance:
85 .sp 94 .sp
86 .RS 4 95 .if n \{\
96 .RS 4
97 .\}
87 .nf 98 .nf
88 add ah, [r10] 99 add ah, [r10]
89 .fi 100 .fi
90 .RE 101 .if n \{\
91 .PP 102 .RE
92 (NASM syntax) is not a legal instruction because the use of r10 requires a REX p refix, making it impossible to use ah. 103 .\}
93 .PP 104 .PP
94 In 64\-bit mode, an additional 8 SSE2 registers are also available. These are na med xmm8\-xmm15. 105 (NASM syntax) is not a legal instruction because the use of r10 requires a REX p refix, making it impossible to use ah\&.
106 .PP
107 In 64\-bit mode, an additional 8 SSE2 registers are also available\&. These are named xmm8\-xmm15\&.
95 .RE 108 .RE
96 .sp 109 .sp
97 .it 1 an-trap 110 .it 1 an-trap
98 .nr an-no-space-flag 1 111 .nr an-no-space-flag 1
99 .nr an-break-flag 1 112 .nr an-break-flag 1
100 .br 113 .br
114 .ps +1
101 \fB64 Bit Instructions\fR 115 \fB64 Bit Instructions\fR
102 .RS 116 .RS 4
103 .PP 117 .PP
104 By default, most operations in 64\-bit mode remain 32\-bit; operations that are 64\-bit usually require a REX prefix (one bit in the REX prefix determines wheth er an operation is 64\-bit or 32\-bit). Thus, essentially all 32\-bit instructio ns have a 64\-bit version, and the 64\-bit versions of instructions can use exte nded registers 118 By default, most operations in 64\-bit mode remain 32\-bit; operations that are 64\-bit usually require a REX prefix (one bit in the REX prefix determines wheth er an operation is 64\-bit or 32\-bit)\&. Thus, essentially all 32\-bit instruct ions have a 64\-bit version, and the 64\-bit versions of instructions can use ex tended registers
105 \(lqfor free\(rq 119 \(lqfor free\(rq
106 (as the REX prefix is already present). Examples in NASM syntax: 120 (as the REX prefix is already present)\&. Examples in NASM syntax:
107 .sp 121 .sp
108 .RS 4 122 .if n \{\
123 .RS 4
124 .\}
109 .nf 125 .nf
110 mov eax, 1 ; 32\-bit instruction 126 mov eax, 1 ; 32\-bit instruction
111 .fi 127 .fi
112 .RE 128 .if n \{\
113 .sp 129 .RE
114 .RS 4 130 .\}
131 .sp
132 .if n \{\
133 .RS 4
134 .\}
115 .nf 135 .nf
116 mov rcx, 1 ; 64\-bit instruction 136 mov rcx, 1 ; 64\-bit instruction
117 .fi 137 .fi
118 .RE 138 .if n \{\
119 .PP 139 .RE
120 Instructions that modify the stack (push, pop, call, ret, enter, and leave) are implicitly 64\-bit. Their 32\-bit counterparts are not available, but their 16\- bit counterparts are. Examples in NASM syntax: 140 .\}
121 .sp 141 .PP
122 .RS 4 142 Instructions that modify the stack (push, pop, call, ret, enter, and leave) are implicitly 64\-bit\&. Their 32\-bit counterparts are not available, but their 16 \-bit counterparts are\&. Examples in NASM syntax:
143 .sp
144 .if n \{\
145 .RS 4
146 .\}
123 .nf 147 .nf
124 push eax ; illegal instruction 148 push eax ; illegal instruction
125 .fi 149 .fi
126 .RE 150 .if n \{\
127 .sp 151 .RE
128 .RS 4 152 .\}
153 .sp
154 .if n \{\
155 .RS 4
156 .\}
129 .nf 157 .nf
130 push rbx ; 1\-byte instruction 158 push rbx ; 1\-byte instruction
131 .fi 159 .fi
132 .RE 160 .if n \{\
133 .sp 161 .RE
134 .RS 4 162 .\}
163 .sp
164 .if n \{\
165 .RS 4
166 .\}
135 .nf 167 .nf
136 push r11 ; 2\-byte instruction with REX prefix 168 push r11 ; 2\-byte instruction with REX prefix
137 .fi 169 .fi
138 .RE 170 .if n \{\
171 .RE
172 .\}
139 .RE 173 .RE
140 .sp 174 .sp
141 .it 1 an-trap 175 .it 1 an-trap
142 .nr an-no-space-flag 1 176 .nr an-no-space-flag 1
143 .nr an-break-flag 1 177 .nr an-break-flag 1
144 .br 178 .br
179 .ps +1
145 \fBImplicit Zero Extension\fR 180 \fBImplicit Zero Extension\fR
146 .RS 181 .RS 4
147 .PP 182 .PP
148 Results of 32\-bit operations are implicitly zero\-extended to the upper 32 bits of the corresponding 64\-bit register. 16 and 8 bit operations, on the other ha nd, do not affect upper bits of the register (just as in 32\-bit and 16\-bit mod es). This can be used to generate smaller code in some instances. Examples in NA SM syntax: 183 Results of 32\-bit operations are implicitly zero\-extended to the upper 32 bits of the corresponding 64\-bit register\&. 16 and 8 bit operations, on the other hand, do not affect upper bits of the register (just as in 32\-bit and 16\-bit m odes)\&. This can be used to generate smaller code in some instances\&. Examples in NASM syntax:
149 .sp 184 .sp
150 .RS 4 185 .if n \{\
186 .RS 4
187 .\}
151 .nf 188 .nf
152 mov ecx, 1 ; 1 byte shorter than mov rcx, 1 189 mov ecx, 1 ; 1 byte shorter than mov rcx, 1
153 .fi 190 .fi
154 .RE 191 .if n \{\
155 .sp 192 .RE
156 .RS 4 193 .\}
194 .sp
195 .if n \{\
196 .RS 4
197 .\}
157 .nf 198 .nf
158 and edx, 3 ; equivalent to and rdx, 3 199 and edx, 3 ; equivalent to and rdx, 3
159 .fi 200 .fi
160 .RE 201 .if n \{\
202 .RE
203 .\}
161 .RE 204 .RE
162 .sp 205 .sp
163 .it 1 an-trap 206 .it 1 an-trap
164 .nr an-no-space-flag 1 207 .nr an-no-space-flag 1
165 .nr an-break-flag 1 208 .nr an-break-flag 1
166 .br 209 .br
210 .ps +1
167 \fBImmediates\fR 211 \fBImmediates\fR
168 .RS 212 .RS 4
169 .PP 213 .PP
170 For most instructions in 64\-bit mode, immediate values remain 32 bits; their va lue is sign\-extended into the upper 32 bits of the target register prior to bei ng used. The exception is the mov instruction, which can take a 64\-bit immediat e when the destination is a 64\-bit register. Examples in NASM syntax: 214 For most instructions in 64\-bit mode, immediate values remain 32 bits; their va lue is sign\-extended into the upper 32 bits of the target register prior to bei ng used\&. The exception is the mov instruction, which can take a 64\-bit immedi ate when the destination is a 64\-bit register\&. Examples in NASM syntax:
171 .sp 215 .sp
172 .RS 4 216 .if n \{\
217 .RS 4
218 .\}
173 .nf 219 .nf
174 add rax, 1 ; optimized down to signed 8\-bit 220 add rax, 1 ; optimized down to signed 8\-bit
175 .fi 221 .fi
176 .RE 222 .if n \{\
177 .sp 223 .RE
178 .RS 4 224 .\}
225 .sp
226 .if n \{\
227 .RS 4
228 .\}
179 .nf 229 .nf
180 add rax, dword 1 ; force size to 32\-bit 230 add rax, dword 1 ; force size to 32\-bit
181 .fi 231 .fi
182 .RE 232 .if n \{\
183 .sp 233 .RE
184 .RS 4 234 .\}
235 .sp
236 .if n \{\
237 .RS 4
238 .\}
185 .nf 239 .nf
186 add rax, 0xffffffff ; sign\-extended 32\-bit 240 add rax, 0xffffffff ; sign\-extended 32\-bit
187 .fi 241 .fi
188 .RE 242 .if n \{\
189 .sp 243 .RE
190 .RS 4 244 .\}
245 .sp
246 .if n \{\
247 .RS 4
248 .\}
191 .nf 249 .nf
192 add rax, \-1 ; same as above 250 add rax, \-1 ; same as above
193 .fi 251 .fi
194 .RE 252 .if n \{\
195 .sp 253 .RE
196 .RS 4 254 .\}
255 .sp
256 .if n \{\
257 .RS 4
258 .\}
197 .nf 259 .nf
198 add rax, 0xffffffffffffffff ; truncated to 32\-bit (warning) 260 add rax, 0xffffffffffffffff ; truncated to 32\-bit (warning)
199 .fi 261 .fi
200 .RE 262 .if n \{\
201 .sp 263 .RE
202 .RS 4 264 .\}
265 .sp
266 .if n \{\
267 .RS 4
268 .\}
203 .nf 269 .nf
204 mov eax, 1 ; 5 byte 270 mov eax, 1 ; 5 byte
205 .fi 271 .fi
206 .RE 272 .if n \{\
207 .sp 273 .RE
208 .RS 4 274 .\}
275 .sp
276 .if n \{\
277 .RS 4
278 .\}
209 .nf 279 .nf
210 mov rax, 1 ; 5 byte (optimized to signed 32\-bit) 280 mov rax, 1 ; 5 byte (optimized to signed 32\-bit)
211 .fi 281 .fi
212 .RE 282 .if n \{\
213 .sp 283 .RE
214 .RS 4 284 .\}
285 .sp
286 .if n \{\
287 .RS 4
288 .\}
215 .nf 289 .nf
216 mov rax, qword 1 ; 10 byte (forced 64\-bit) 290 mov rax, qword 1 ; 10 byte (forced 64\-bit)
217 .fi 291 .fi
218 .RE 292 .if n \{\
219 .sp 293 .RE
220 .RS 4 294 .\}
295 .sp
296 .if n \{\
297 .RS 4
298 .\}
221 .nf 299 .nf
222 mov rbx, 0x1234567890abcdef ; 10 byte 300 mov rbx, 0x1234567890abcdef ; 10 byte
223 .fi 301 .fi
224 .RE 302 .if n \{\
225 .sp 303 .RE
226 .RS 4 304 .\}
305 .sp
306 .if n \{\
307 .RS 4
308 .\}
227 .nf 309 .nf
228 mov rcx, 0xffffffff ; 10 byte (does not fit in signed 32\-bit) 310 mov rcx, 0xffffffff ; 10 byte (does not fit in signed 32\-bit)
229 .fi 311 .fi
230 .RE 312 .if n \{\
231 .sp 313 .RE
232 .RS 4 314 .\}
315 .sp
316 .if n \{\
317 .RS 4
318 .\}
233 .nf 319 .nf
234 mov ecx, \-1 ; 5 byte, equivalent to above 320 mov ecx, \-1 ; 5 byte, equivalent to above
235 .fi 321 .fi
236 .RE 322 .if n \{\
237 .sp 323 .RE
238 .RS 4 324 .\}
325 .sp
326 .if n \{\
327 .RS 4
328 .\}
239 .nf 329 .nf
240 mov rcx, sym ; 5 byte, 32\-bit size default for symbols 330 mov rcx, sym ; 5 byte, 32\-bit size default for symbols
241 .fi 331 .fi
242 .RE 332 .if n \{\
243 .sp 333 .RE
244 .RS 4 334 .\}
335 .sp
336 .if n \{\
337 .RS 4
338 .\}
245 .nf 339 .nf
246 mov rcx, qword sym ; 10 byte, override default size 340 mov rcx, qword sym ; 10 byte, override default size
247 .fi 341 .fi
248 .RE 342 .if n \{\
249 .PP 343 .RE
250 The handling of mov reg64, unsized immediate is different between YASM and NASM 2.x; YASM follows the above behavior, while NASM 2.x does the following: 344 .\}
251 .sp 345 .PP
252 .RS 4 346 The handling of mov reg64, unsized immediate is different between YASM and NASM 2\&.x; YASM follows the above behavior, while NASM 2\&.x does the following:
347 .sp
348 .if n \{\
349 .RS 4
350 .\}
253 .nf 351 .nf
254 add rax, 0xffffffff ; sign\-extended 32\-bit immediate 352 add rax, 0xffffffff ; sign\-extended 32\-bit immediate
255 .fi 353 .fi
256 .RE 354 .if n \{\
257 .sp 355 .RE
258 .RS 4 356 .\}
357 .sp
358 .if n \{\
359 .RS 4
360 .\}
259 .nf 361 .nf
260 add rax, \-1 ; same as above 362 add rax, \-1 ; same as above
261 .fi 363 .fi
262 .RE 364 .if n \{\
263 .sp 365 .RE
264 .RS 4 366 .\}
367 .sp
368 .if n \{\
369 .RS 4
370 .\}
265 .nf 371 .nf
266 add rax, 0xffffffffffffffff ; truncated 32\-bit (warning) 372 add rax, 0xffffffffffffffff ; truncated 32\-bit (warning)
267 .fi 373 .fi
268 .RE 374 .if n \{\
269 .sp 375 .RE
270 .RS 4 376 .\}
377 .sp
378 .if n \{\
379 .RS 4
380 .\}
271 .nf 381 .nf
272 add rax, sym ; sign\-extended 32\-bit immediate 382 add rax, sym ; sign\-extended 32\-bit immediate
273 .fi 383 .fi
274 .RE 384 .if n \{\
275 .sp 385 .RE
276 .RS 4 386 .\}
387 .sp
388 .if n \{\
389 .RS 4
390 .\}
277 .nf 391 .nf
278 mov eax, 1 ; 5 byte (32\-bit immediate) 392 mov eax, 1 ; 5 byte (32\-bit immediate)
279 .fi 393 .fi
280 .RE 394 .if n \{\
281 .sp 395 .RE
282 .RS 4 396 .\}
397 .sp
398 .if n \{\
399 .RS 4
400 .\}
283 .nf 401 .nf
284 mov rax, 1 ; 10 byte (64\-bit immediate) 402 mov rax, 1 ; 10 byte (64\-bit immediate)
285 .fi 403 .fi
286 .RE 404 .if n \{\
287 .sp 405 .RE
288 .RS 4 406 .\}
407 .sp
408 .if n \{\
409 .RS 4
410 .\}
289 .nf 411 .nf
290 mov rbx, 0x1234567890abcdef ; 10 byte instruction 412 mov rbx, 0x1234567890abcdef ; 10 byte instruction
291 .fi 413 .fi
292 .RE 414 .if n \{\
293 .sp 415 .RE
294 .RS 4 416 .\}
417 .sp
418 .if n \{\
419 .RS 4
420 .\}
295 .nf 421 .nf
296 mov rcx, 0xffffffff ; 10 byte instruction 422 mov rcx, 0xffffffff ; 10 byte instruction
297 .fi 423 .fi
298 .RE 424 .if n \{\
299 .sp 425 .RE
300 .RS 4 426 .\}
427 .sp
428 .if n \{\
429 .RS 4
430 .\}
301 .nf 431 .nf
302 mov ecx, \-1 ; 5 byte, equivalent to above 432 mov ecx, \-1 ; 5 byte, equivalent to above
303 .fi 433 .fi
304 .RE 434 .if n \{\
305 .sp 435 .RE
306 .RS 4 436 .\}
437 .sp
438 .if n \{\
439 .RS 4
440 .\}
307 .nf 441 .nf
308 mov ecx, sym ; 5 byte (32\-bit immediate) 442 mov ecx, sym ; 5 byte (32\-bit immediate)
309 .fi 443 .fi
310 .RE 444 .if n \{\
311 .sp 445 .RE
312 .RS 4 446 .\}
447 .sp
448 .if n \{\
449 .RS 4
450 .\}
313 .nf 451 .nf
314 mov rcx, sym ; 10 byte instruction 452 mov rcx, sym ; 10 byte instruction
315 .fi 453 .fi
316 .RE 454 .if n \{\
317 .sp 455 .RE
318 .RS 4 456 .\}
457 .sp
458 .if n \{\
459 .RS 4
460 .\}
319 .nf 461 .nf
320 mov rcx, qword sym ; 10 byte (64\-bit immediate) 462 mov rcx, qword sym ; 10 byte (64\-bit immediate)
321 .fi 463 .fi
322 .RE 464 .if n \{\
465 .RE
466 .\}
323 .RE 467 .RE
324 .sp 468 .sp
325 .it 1 an-trap 469 .it 1 an-trap
326 .nr an-no-space-flag 1 470 .nr an-no-space-flag 1
327 .nr an-break-flag 1 471 .nr an-break-flag 1
328 .br 472 .br
473 .ps +1
329 \fBDisplacements\fR 474 \fBDisplacements\fR
330 .RS 475 .RS 4
331 .PP 476 .PP
332 Just like immediates, displacements, for the most part, remain 32 bits and are s ign extended prior to use. Again, the exception is one restricted form of the mo v instruction: between the al/ax/eax/rax register and a 64\-bit absolute address (no registers allowed in the effective address). In NASM syntax, use of the 64\ -bit absolute form requires 477 Just like immediates, displacements, for the most part, remain 32 bits and are s ign extended prior to use\&. Again, the exception is one restricted form of the mov instruction: between the al/ax/eax/rax register and a 64\-bit absolute addre ss (no registers allowed in the effective address)\&. In NASM syntax, use of the 64\-bit absolute form requires
333 \fB[qword]\fR. Examples in NASM syntax: 478 \fB[qword]\fR\&. Examples in NASM syntax:
334 .sp 479 .sp
335 .RS 4 480 .if n \{\
481 .RS 4
482 .\}
336 .nf 483 .nf
337 mov eax, [1] ; 32 bit, with sign extension 484 mov eax, [1] ; 32 bit, with sign extension
338 .fi 485 .fi
339 .RE 486 .if n \{\
340 .sp 487 .RE
341 .RS 4 488 .\}
489 .sp
490 .if n \{\
491 .RS 4
492 .\}
342 .nf 493 .nf
343 mov al, [rax\-1] ; 32 bit, with sign extension 494 mov al, [rax\-1] ; 32 bit, with sign extension
344 .fi 495 .fi
345 .RE 496 .if n \{\
346 .sp 497 .RE
347 .RS 4 498 .\}
499 .sp
500 .if n \{\
501 .RS 4
502 .\}
348 .nf 503 .nf
349 mov al, [qword 0x1122334455667788] ; 64\-bit absolute 504 mov al, [qword 0x1122334455667788] ; 64\-bit absolute
350 .fi 505 .fi
351 .RE 506 .if n \{\
352 .sp 507 .RE
353 .RS 4 508 .\}
509 .sp
510 .if n \{\
511 .RS 4
512 .\}
354 .nf 513 .nf
355 mov al, [0x1122334455667788] ; truncated to 32\-bit (warning) 514 mov al, [0x1122334455667788] ; truncated to 32\-bit (warning)
356 .fi 515 .fi
357 .RE 516 .if n \{\
517 .RE
518 .\}
358 .RE 519 .RE
359 .sp 520 .sp
360 .it 1 an-trap 521 .it 1 an-trap
361 .nr an-no-space-flag 1 522 .nr an-no-space-flag 1
362 .nr an-break-flag 1 523 .nr an-break-flag 1
363 .br 524 .br
525 .ps +1
364 \fBRIP Relative Addressing\fR 526 \fBRIP Relative Addressing\fR
365 .RS 527 .RS 4
366 .PP 528 .PP
367 In 64\-bit mode, a new form of effective addressing is available to make it easi er to write position\-independent code. Any memory reference may be made RIP rel ative (RIP is the instruction pointer register, which contains the address of th e location immediately following the current instruction). 529 In 64\-bit mode, a new form of effective addressing is available to make it easi er to write position\-independent code\&. Any memory reference may be made RIP r elative (RIP is the instruction pointer register, which contains the address of the location immediately following the current instruction)\&.
368 .PP 530 .PP
369 In NASM syntax, there are two ways to specify RIP\-relative addressing: 531 In NASM syntax, there are two ways to specify RIP\-relative addressing:
370 .sp 532 .sp
371 .RS 4 533 .if n \{\
534 .RS 4
535 .\}
372 .nf 536 .nf
373 mov dword [rip+10], 1 537 mov dword [rip+10], 1
374 .fi 538 .fi
375 .RE 539 .if n \{\
376 .PP 540 .RE
377 stores the value 1 ten bytes after the end of the instruction. 541 .\}
542 .PP
543 stores the value 1 ten bytes after the end of the instruction\&.
378 \fB10\fR 544 \fB10\fR
379 can also be a symbolic constant, and will be treated the same way. On the other hand, 545 can also be a symbolic constant, and will be treated the same way\&. On the othe r hand,
380 .sp 546 .sp
381 .RS 4 547 .if n \{\
548 .RS 4
549 .\}
382 .nf 550 .nf
383 mov dword [symb wrt rip], 1 551 mov dword [symb wrt rip], 1
384 .fi 552 .fi
385 .RE 553 .if n \{\
554 .RE
555 .\}
386 .PP 556 .PP
387 stores the value 1 into the address of symbol 557 stores the value 1 into the address of symbol
388 \fBsymb\fR. This is distinctly different than the behavior of: 558 \fBsymb\fR\&. This is distinctly different than the behavior of:
389 .sp 559 .sp
390 .RS 4 560 .if n \{\
561 .RS 4
562 .\}
391 .nf 563 .nf
392 mov dword [symb+rip], 1 564 mov dword [symb+rip], 1
393 .fi 565 .fi
394 .RE 566 .if n \{\
567 .RE
568 .\}
395 .PP 569 .PP
396 which takes the address of the end of the instruction, adds the address of 570 which takes the address of the end of the instruction, adds the address of
397 \fBsymb\fR 571 \fBsymb\fR
398 to it, then stores the value 1 there. If 572 to it, then stores the value 1 there\&. If
399 \fBsymb\fR 573 \fBsymb\fR
400 is a variable, this will 574 is a variable, this will
401 \fInot\fR 575 \fInot\fR
402 store the value 1 into the 576 store the value 1 into the
403 \fBsymb\fR 577 \fBsymb\fR
404 variable! 578 variable!
405 .PP 579 .PP
406 Yasm also supports the following syntax for RIP\-relative addressing: 580 Yasm also supports the following syntax for RIP\-relative addressing:
407 .sp 581 .sp
408 .RS 4 582 .if n \{\
583 .RS 4
584 .\}
409 .nf 585 .nf
410 mov [rel sym], rax ; RIP\-relative 586 mov [rel sym], rax ; RIP\-relative
411 .fi 587 .fi
412 .RE 588 .if n \{\
413 .sp 589 .RE
414 .RS 4 590 .\}
591 .sp
592 .if n \{\
593 .RS 4
594 .\}
415 .nf 595 .nf
416 mov [abs sym], rax ; not RIP\-relative 596 mov [abs sym], rax ; not RIP\-relative
417 .fi 597 .fi
418 .RE 598 .if n \{\
599 .RE
600 .\}
419 .PP 601 .PP
420 The behavior of: 602 The behavior of:
421 .sp 603 .sp
422 .RS 4 604 .if n \{\
605 .RS 4
606 .\}
423 .nf 607 .nf
424 mov [sym], rax 608 mov [sym], rax
425 .fi 609 .fi
426 .RE 610 .if n \{\
427 .PP 611 .RE
428 Depends on a mode set by the DEFAULT directive, as follows. The default mode is always "abs", and in "rel" mode, use of registers, an fs or gs segment override, or an explicit "abs" override will result in a non\-RIP\-relative effective add ress. 612 .\}
429 .sp 613 .PP
430 .RS 4 614 Depends on a mode set by the DEFAULT directive, as follows\&. The default mode i s always "abs", and in "rel" mode, use of registers, an fs or gs segment overrid e, or an explicit "abs" override will result in a non\-RIP\-relative effective a ddress\&.
615 .sp
616 .if n \{\
617 .RS 4
618 .\}
431 .nf 619 .nf
432 default rel 620 default rel
433 .fi 621 .fi
434 .RE 622 .if n \{\
435 .sp 623 .RE
436 .RS 4 624 .\}
625 .sp
626 .if n \{\
627 .RS 4
628 .\}
437 .nf 629 .nf
438 mov [sym], rbx ; RIP\-relative 630 mov [sym], rbx ; RIP\-relative
439 .fi 631 .fi
440 .RE 632 .if n \{\
441 .sp 633 .RE
442 .RS 4 634 .\}
635 .sp
636 .if n \{\
637 .RS 4
638 .\}
443 .nf 639 .nf
444 mov [abs sym], rbx ; not RIP\-relative (explicit override) 640 mov [abs sym], rbx ; not RIP\-relative (explicit override)
445 .fi 641 .fi
446 .RE 642 .if n \{\
447 .sp 643 .RE
448 .RS 4 644 .\}
645 .sp
646 .if n \{\
647 .RS 4
648 .\}
449 .nf 649 .nf
450 mov [rbx+1], rbx ; not RIP\-relative (register use) 650 mov [rbx+1], rbx ; not RIP\-relative (register use)
451 .fi 651 .fi
452 .RE 652 .if n \{\
453 .sp 653 .RE
454 .RS 4 654 .\}
655 .sp
656 .if n \{\
657 .RS 4
658 .\}
455 .nf 659 .nf
456 mov [fs:sym], rbx ; not RIP\-relative (fs or gs use) 660 mov [fs:sym], rbx ; not RIP\-relative (fs or gs use)
457 .fi 661 .fi
458 .RE 662 .if n \{\
459 .sp 663 .RE
460 .RS 4 664 .\}
665 .sp
666 .if n \{\
667 .RS 4
668 .\}
461 .nf 669 .nf
462 mov [ds:sym], rbx ; RIP\-relative (segment, but not fs or gs) 670 mov [ds:sym], rbx ; RIP\-relative (segment, but not fs or gs)
463 .fi 671 .fi
464 .RE 672 .if n \{\
465 .sp 673 .RE
466 .RS 4 674 .\}
675 .sp
676 .if n \{\
677 .RS 4
678 .\}
467 .nf 679 .nf
468 mov [rel sym], rbx ; RIP\-relative (redundant override) 680 mov [rel sym], rbx ; RIP\-relative (redundant override)
469 .fi 681 .fi
470 .RE 682 .if n \{\
471 .sp 683 .RE
472 .RS 4 684 .\}
685 .sp
686 .if n \{\
687 .RS 4
688 .\}
473 .nf 689 .nf
474 default abs 690 default abs
475 .fi 691 .fi
476 .RE 692 .if n \{\
477 .sp 693 .RE
478 .RS 4 694 .\}
695 .sp
696 .if n \{\
697 .RS 4
698 .\}
479 .nf 699 .nf
480 mov [sym], rbx ; not RIP\-relative 700 mov [sym], rbx ; not RIP\-relative
481 .fi 701 .fi
482 .RE 702 .if n \{\
483 .sp 703 .RE
484 .RS 4 704 .\}
705 .sp
706 .if n \{\
707 .RS 4
708 .\}
485 .nf 709 .nf
486 mov [abs sym], rbx ; not RIP\-relative 710 mov [abs sym], rbx ; not RIP\-relative
487 .fi 711 .fi
488 .RE 712 .if n \{\
489 .sp 713 .RE
490 .RS 4 714 .\}
715 .sp
716 .if n \{\
717 .RS 4
718 .\}
491 .nf 719 .nf
492 mov [rbx+1], rbx ; not RIP\-relative 720 mov [rbx+1], rbx ; not RIP\-relative
493 .fi 721 .fi
494 .RE 722 .if n \{\
495 .sp 723 .RE
496 .RS 4 724 .\}
725 .sp
726 .if n \{\
727 .RS 4
728 .\}
497 .nf 729 .nf
498 mov [fs:sym], rbx ; not RIP\-relative 730 mov [fs:sym], rbx ; not RIP\-relative
499 .fi 731 .fi
500 .RE 732 .if n \{\
501 .sp 733 .RE
502 .RS 4 734 .\}
735 .sp
736 .if n \{\
737 .RS 4
738 .\}
503 .nf 739 .nf
504 mov [ds:sym], rbx ; not RIP\-relative 740 mov [ds:sym], rbx ; not RIP\-relative
505 .fi 741 .fi
506 .RE 742 .if n \{\
507 .sp 743 .RE
508 .RS 4 744 .\}
745 .sp
746 .if n \{\
747 .RS 4
748 .\}
509 .nf 749 .nf
510 mov [rel sym], rbx ; RIP\-relative (explicit override) 750 mov [rel sym], rbx ; RIP\-relative (explicit override)
511 .fi 751 .fi
512 .RE 752 .if n \{\
753 .RE
754 .\}
513 .RE 755 .RE
514 .sp 756 .sp
515 .it 1 an-trap 757 .it 1 an-trap
516 .nr an-no-space-flag 1 758 .nr an-no-space-flag 1
517 .nr an-break-flag 1 759 .nr an-break-flag 1
518 .br 760 .br
761 .ps +1
519 \fBMemory references\fR 762 \fBMemory references\fR
520 .RS 763 .RS 4
521 .PP 764 .PP
522 Usually the size of a memory reference can be deduced by which registers you're moving\-\-for example, "mov [rax],ecx" is a 32\-bit move, because ecx is 32 bits . YASM currently gives the non\-obvious "invalid combination of opcode and opera nds" error if it can't figure out how much memory you're moving. The fix in this case is to add a memory size specifier: qword, dword, word, or byte. 765 Usually the size of a memory reference can be deduced by which registers you\'re moving\-\-for example, "mov [rax],ecx" is a 32\-bit move, because ecx is 32 bit s\&. YASM currently gives the non\-obvious "invalid combination of opcode and op erands" error if it can\'t figure out how much memory you\'re moving\&. The fix in this case is to add a memory size specifier: qword, dword, word, or byte\&.
523 .PP 766 .PP
524 Here's a 64\-bit memory move, which sets 8 bytes starting at rax: 767 Here\'s a 64\-bit memory move, which sets 8 bytes starting at rax:
525 .sp 768 .sp
526 .RS 4 769 .if n \{\
770 .RS 4
771 .\}
527 .nf 772 .nf
528 mov qword [rax], 1 773 mov qword [rax], 1
529 .fi 774 .fi
530 .RE 775 .if n \{\
531 .PP 776 .RE
532 Here's a 32\-bit memory move, which sets 4 bytes: 777 .\}
533 .sp 778 .PP
534 .RS 4 779 Here\'s a 32\-bit memory move, which sets 4 bytes:
780 .sp
781 .if n \{\
782 .RS 4
783 .\}
535 .nf 784 .nf
536 mov dword [rax], 1 785 mov dword [rax], 1
537 .fi 786 .fi
538 .RE 787 .if n \{\
539 .PP 788 .RE
540 Here's a 16\-bit memory move, which sets 2 bytes: 789 .\}
541 .sp 790 .PP
542 .RS 4 791 Here\'s a 16\-bit memory move, which sets 2 bytes:
792 .sp
793 .if n \{\
794 .RS 4
795 .\}
543 .nf 796 .nf
544 mov word [rax], 1 797 mov word [rax], 1
545 .fi 798 .fi
546 .RE 799 .if n \{\
547 .PP 800 .RE
548 Here's an 8\-bit memory move, which sets 1 byte: 801 .\}
549 .sp 802 .PP
550 .RS 4 803 Here\'s an 8\-bit memory move, which sets 1 byte:
804 .sp
805 .if n \{\
806 .RS 4
807 .\}
551 .nf 808 .nf
552 mov byte [rax], 1 809 mov byte [rax], 1
553 .fi 810 .fi
554 .RE 811 .if n \{\
812 .RE
813 .\}
555 .RE 814 .RE
556 .SH "LC3B ARCHITECTURE" 815 .SH "LC3B ARCHITECTURE"
557 .PP 816 .PP
558 The 817 The
559 \(lqlc3b\(rq 818 \(lqlc3b\(rq
560 architecture supports the LC\-3b ISA as used in the ECE 312 (now ECE 411) course at the University of Illinois, Urbana\-Champaign, as well as other university c ourses. See 819 architecture supports the LC\-3b ISA as used in the ECE 312 (now ECE 411) course at the University of Illinois, Urbana\-Champaign, as well as other university c ourses\&. See
561 \fI\%http://courses.ece.uiuc.edu/ece411/\fR 820 \m[blue]\fB\%http://courses.ece.uiuc.edu/ece411/\fR\m[]
562 for more details and example code. The 821 for more details and example code\&. The
563 \(lqlc3b\(rq 822 \(lqlc3b\(rq
564 architecture consists of only one machine: 823 architecture consists of only one machine:
565 \(lqlc3b\(rq. 824 \(lqlc3b\(rq\&.
566 .SH "SEE ALSO" 825 .SH "SEE ALSO"
567 .PP 826 .PP
568 \fByasm\fR(1) 827 \fByasm\fR(1)
569 .SH "BUGS" 828 .SH "BUGS"
570 .PP 829 .PP
571 When using the 830 When using the
572 \(lqx86\(rq 831 \(lqx86\(rq
573 architecture, it is overly easy to generate AMD64 code (using the 832 architecture, it is overly easy to generate AMD64 code (using the
574 \fBBITS 64\fR 833 \fBBITS 64\fR
575 directive) and generate a 32\-bit object file (by failing to specify 834 directive) and generate a 32\-bit object file (by failing to specify
576 \fB\-m amd64\fR 835 \fB\-m amd64\fR
577 on the command line or selecting a 64\-bit object format). Similarly, specifying 836 on the command line or selecting a 64\-bit object format)\&. Similarly, specifyi ng
578 \fB\-m amd64\fR 837 \fB\-m amd64\fR
579 does not default the BITS setting to 64. An easy way to avoid this is by directl y specifying a 64\-bit object format such as 838 does not default the BITS setting to 64\&. An easy way to avoid this is by direc tly specifying a 64\-bit object format such as
580 \fB\-f elf64\fR. 839 \fB\-f elf64\fR\&.
581 .SH "AUTHOR" 840 .SH "AUTHOR"
582 .PP 841 .PP
583 \fBPeter Johnson\fR <\&peter@tortall.net\&> 842 \fBPeter Johnson\fR <\&peter@tortall\&.net\&>
584 .sp -1n 843 .RS 4
585 .IP "" 4
586 Author. 844 Author.
845 .RE
587 .SH "COPYRIGHT" 846 .SH "COPYRIGHT"
847 .br
588 Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson 848 Copyright \(co 2004, 2005, 2006, 2007 Peter Johnson
589 .br 849 .br
590
OLDNEW
« no previous file with comments | « third_party/yasm/patched-yasm/po/yasm.pot ('k') | third_party/yasm/patched-yasm/yasm_parsers.7 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698