Upload Tizen:Base source
[external/binutils.git] / gas / doc / c-sparc.texi
1 @c Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2002, 2008,
2 @c 2011
3 @c Free Software Foundation, Inc.
4 @c This is part of the GAS manual.
5 @c For copying conditions, see the file as.texinfo.
6 @ifset GENERIC
7 @page
8 @node Sparc-Dependent
9 @chapter SPARC Dependent Features
10 @end ifset
11 @ifclear GENERIC
12 @node Machine Dependencies
13 @chapter SPARC Dependent Features
14 @end ifclear
15
16 @cindex SPARC support
17 @menu
18 * Sparc-Opts::                  Options
19 * Sparc-Aligned-Data::          Option to enforce aligned data
20 * Sparc-Syntax::                Syntax
21 * Sparc-Float::                 Floating Point
22 * Sparc-Directives::            Sparc Machine Directives
23 @end menu
24
25 @node Sparc-Opts
26 @section Options
27
28 @cindex options for SPARC
29 @cindex SPARC options
30 @cindex architectures, SPARC
31 @cindex SPARC architectures
32 The SPARC chip family includes several successive versions, using the same
33 core instruction set, but including a few additional instructions at
34 each version.  There are exceptions to this however.  For details on what
35 instructions each variant supports, please see the chip's architecture
36 reference manual.
37
38 By default, @code{@value{AS}} assumes the core instruction set (SPARC
39 v6), but ``bumps'' the architecture level as needed: it switches to
40 successively higher architectures as it encounters instructions that
41 only exist in the higher levels.
42
43 If not configured for SPARC v9 (@code{sparc64-*-*}) GAS will not bump
44 past sparclite by default, an option must be passed to enable the
45 v9 instructions.
46
47 GAS treats sparclite as being compatible with v8, unless an architecture
48 is explicitly requested.  SPARC v9 is always incompatible with sparclite.
49
50 @c The order here is the same as the order of enum sparc_opcode_arch_val
51 @c to give the user a sense of the order of the "bumping".
52
53 @table @code
54 @kindex -Av6
55 @kindex Av7
56 @kindex -Av8
57 @kindex -Asparclet
58 @kindex -Asparclite
59 @kindex -Av9
60 @kindex -Av9a
61 @item -Av6 | -Av7 | -Av8 | -Asparclet | -Asparclite
62 @itemx -Av8plus | -Av8plusa | -Av9 | -Av9a
63 Use one of the @samp{-A} options to select one of the SPARC
64 architectures explicitly.  If you select an architecture explicitly,
65 @code{@value{AS}} reports a fatal error if it encounters an instruction
66 or feature requiring an incompatible or higher level.
67
68 @samp{-Av8plus} and @samp{-Av8plusa} select a 32 bit environment.
69
70 @samp{-Av9} and @samp{-Av9a} select a 64 bit environment and are not
71 available unless GAS is explicitly configured with 64 bit environment
72 support.
73
74 @samp{-Av8plusa} and @samp{-Av9a} enable the SPARC V9 instruction set with
75 UltraSPARC extensions.
76
77 @item -xarch=v8plus | -xarch=v8plusa
78 For compatibility with the SunOS v9 assembler.  These options are
79 equivalent to -Av8plus and -Av8plusa, respectively.
80
81 @item -bump
82 Warn whenever it is necessary to switch to another level.
83 If an architecture level is explicitly requested, GAS will not issue
84 warnings until that level is reached, and will then bump the level
85 as required (except between incompatible levels).
86
87 @item -32 | -64
88 Select the word size, either 32 bits or 64 bits.
89 These options are only available with the ELF object file format,
90 and require that the necessary BFD support has been included.
91 @end table
92
93 @node Sparc-Aligned-Data
94 @section Enforcing aligned data
95
96 @cindex data alignment on SPARC
97 @cindex SPARC data alignment
98 SPARC GAS normally permits data to be misaligned.  For example, it
99 permits the @code{.long} pseudo-op to be used on a byte boundary.
100 However, the native SunOS assemblers issue an error when they see
101 misaligned data.
102
103 @kindex --enforce-aligned-data
104 You can use the @code{--enforce-aligned-data} option to make SPARC GAS
105 also issue an error about misaligned data, just as the SunOS
106 assemblers do.
107
108 The @code{--enforce-aligned-data} option is not the default because gcc
109 issues misaligned data pseudo-ops when it initializes certain packed
110 data structures (structures defined using the @code{packed} attribute).
111 You may have to assemble with GAS in order to initialize packed data
112 structures in your own code.
113
114 @cindex SPARC syntax
115 @cindex syntax, SPARC
116 @node Sparc-Syntax
117 @section Sparc Syntax
118 The assembler syntax closely follows The Sparc Architecture Manual,
119 versions 8 and 9, as well as most extensions defined by Sun
120 for their UltraSPARC and Niagara line of processors.
121
122 @menu
123 * Sparc-Chars::                Special Characters
124 * Sparc-Regs::                 Register Names
125 * Sparc-Constants::            Constant Names
126 * Sparc-Relocs::               Relocations
127 * Sparc-Size-Translations::    Size Translations
128 @end menu
129
130 @node Sparc-Chars
131 @subsection Special Characters
132
133 @cindex line comment character, Sparc
134 @cindex Sparc line comment character
135 A @samp{!} character appearing anywhere on a line indicates the start
136 of a comment that extends to the end of that line.
137
138 If a @samp{#} appears as the first character of a line then the whole
139 line is treated as a comment, but in this case the line could also be
140 a logical line number directive (@pxref{Comments}) or a preprocessor
141 control command (@pxref{Preprocessing}).
142
143 @cindex line separator, Sparc
144 @cindex statement separator, Sparc
145 @cindex Sparc line separator
146 @samp{;} can be used instead of a newline to separate statements.
147
148 @node Sparc-Regs
149 @subsection Register Names
150 @cindex Sparc registers
151 @cindex register names, Sparc
152
153 The Sparc integer register file is broken down into global,
154 outgoing, local, and incoming.
155
156 @itemize @bullet
157 @item
158 The 8 global registers are referred to as @samp{%g@var{n}}.
159
160 @item
161 The 8 outgoing registers are referred to as @samp{%o@var{n}}.
162
163 @item
164 The 8 local registers are referred to as @samp{%l@var{n}}.
165
166 @item
167 The 8 incoming registers are referred to as @samp{%i@var{n}}.
168
169 @item
170 The frame pointer register @samp{%i6} can be referenced using
171 the alias @samp{%fp}.
172
173 @item
174 The stack pointer register @samp{%o6} can be referenced using
175 the alias @samp{%sp}.
176 @end itemize
177
178 Floating point registers are simply referred to as @samp{%f@var{n}}.
179 When assembling for pre-V9, only 32 floating point registers
180 are available.  For V9 and later there are 64, but there are
181 restrictions when referencing the upper 32 registers.  They
182 can only be accessed as double or quad, and thus only even
183 or quad numbered accesses are allowed.  For example, @samp{%f34}
184 is a legal floating point register, but @samp{%f35} is not.
185
186 Certain V9 instructions allow access to ancillary state registers.
187 Most simply they can be referred to as @samp{%asr@var{n}} where
188 @var{n} can be from 16 to 31.  However, there are some aliases
189 defined to reference ASR registers defined for various UltraSPARC
190 processors:
191
192 @itemize @bullet
193 @item
194 The tick compare register is referred to as @samp{%tick_cmpr}.
195
196 @item
197 The system tick register is referred to as @samp{%stick}.  An alias,
198 @samp{%sys_tick}, exists but is deprecated and should not be used
199 by new software.
200
201 @item
202 The system tick compare register is referred to as @samp{%stick_cmpr}.
203 An alias, @samp{%sys_tick_cmpr}, exists but is deprecated and should
204 not be used by new software.
205
206 @item
207 The software interrupt register is referred to as @samp{%softint}.
208
209 @item
210 The set software interrupt register is referred to as @samp{%set_softint}.
211 The mnemonic @samp{%softint_set} is provided as an alias.
212
213 @item
214 The clear software interrupt register is referred to as
215 @samp{%clear_softint}.  The mnemonic @samp{%softint_clear} is provided
216 as an alias.
217
218 @item
219 The performance instrumentation counters register is referred to as
220 @samp{%pic}.
221
222 @item
223 The performance control register is referred to as @samp{%pcr}.
224
225 @item
226 The graphics status register is referred to as @samp{%gsr}.
227
228 @item
229 The V9 dispatch control register is referred to as @samp{%dcr}.
230 @end itemize
231
232 Various V9 branch and conditional move instructions allow
233 specification of which set of integer condition codes to
234 test.  These are referred to as @samp{%xcc} and @samp{%icc}.
235
236 In V9, there are 4 sets of floating point condition codes
237 which are referred to as @samp{%fcc@var{n}}.
238
239 Several special privileged and non-privileged registers
240 exist:
241
242 @itemize @bullet
243 @item
244 The V9 address space identifier register is referred to as @samp{%asi}.
245
246 @item
247 The V9 restorable windows register is referred to as @samp{%canrestore}.
248
249 @item
250 The V9 savable windows register is referred to as @samp{%cansave}.
251
252 @item
253 The V9 clean windows register is referred to as @samp{%cleanwin}.
254
255 @item
256 The V9 current window pointer register is referred to as @samp{%cwp}.
257
258 @item
259 The floating-point queue register is referred to as @samp{%fq}.
260
261 @item
262 The V8 co-processor queue register is referred to as @samp{%cq}.
263
264 @item
265 The floating point status register is referred to as @samp{%fsr}.
266
267 @item
268 The other windows register is referred to as @samp{%otherwin}.
269
270 @item
271 The V9 program counter register is referred to as @samp{%pc}.
272
273 @item
274 The V9 next program counter register is referred to as @samp{%npc}.
275
276 @item
277 The V9 processor interrupt level register is referred to as @samp{%pil}.
278
279 @item
280 The V9 processor state register is referred to as @samp{%pstate}.
281
282 @item
283 The trap base address register is referred to as @samp{%tba}.
284
285 @item
286 The V9 tick register is referred to as @samp{%tick}.
287
288 @item
289 The V9 trap level is referred to as @samp{%tl}.
290
291 @item
292 The V9 trap program counter is referred to as @samp{%tpc}.
293
294 @item
295 The V9 trap next program counter is referred to as @samp{%tnpc}.
296
297 @item
298 The V9 trap state is referred to as @samp{%tstate}.
299
300 @item
301 The V9 trap type is referred to as @samp{%tt}.
302
303 @item
304 The V9 condition codes is referred to as @samp{%ccr}.
305
306 @item
307 The V9 floating-point registers state is referred to as @samp{%fprs}.
308
309 @item
310 The V9 version register is referred to as @samp{%ver}.
311
312 @item
313 The V9 window state register is referred to as @samp{%wstate}.
314
315 @item
316 The Y register is referred to as @samp{%y}.
317
318 @item
319 The V8 window invalid mask register is referred to as @samp{%wim}.
320
321 @item
322 The V8 processor state register is referred to as @samp{%psr}.
323
324 @item
325 The V9 global register level register is referred to as @samp{%gl}.
326 @end itemize
327
328 Several special register names exist for hypervisor mode code:
329
330 @itemize @bullet
331 @item
332 The hyperprivileged processor state register is referred to as
333 @samp{%hpstate}.
334
335 @item
336 The hyperprivileged trap state register is referred to as @samp{%htstate}.
337
338 @item
339 The hyperprivileged interrupt pending register is referred to as
340 @samp{%hintp}.
341
342 @item
343 The hyperprivileged trap base address register is referred to as
344 @samp{%htba}.
345
346 @item
347 The hyperprivileged implementation version register is referred
348 to as @samp{%hver}.
349
350 @item
351 The hyperprivileged system tick compare register is referred
352 to as @samp{%hstick_cmpr}.  Note that there is no @samp{%hstick}
353 register, the normal @samp{%stick} is used.
354 @end itemize
355
356 @node Sparc-Constants
357 @subsection Constants
358 @cindex Sparc constants
359 @cindex constants, Sparc
360
361 Several Sparc instructions take an immediate operand field for
362 which mnemonic names exist.  Two such examples are @samp{membar}
363 and @samp{prefetch}.  Another example are the set of V9
364 memory access instruction that allow specification of an
365 address space identifier.
366
367 The @samp{membar} instruction specifies a memory barrier that is
368 the defined by the operand which is a bitmask.  The supported
369 mask mnemonics are:
370
371 @itemize @bullet
372 @item
373 @samp{#Sync} requests that all operations (including nonmemory
374 reference operations) appearing prior to the @code{membar} must have
375 been performed and the effects of any exceptions become visible before
376 any instructions after the @code{membar} may be initiated.  This
377 corresponds to @code{membar} cmask field bit 2.
378
379 @item
380 @samp{#MemIssue} requests that all memory reference operations
381 appearing prior to the @code{membar} must have been performed before
382 any memory operation after the @code{membar} may be initiated.  This
383 corresponds to @code{membar} cmask field bit 1.
384
385 @item
386 @samp{#Lookaside} requests that a store appearing prior to the
387 @code{membar} must complete before any load following the
388 @code{membar} referencing the same address can be initiated.  This
389 corresponds to @code{membar} cmask field bit 0.
390
391 @item
392 @samp{#StoreStore} defines that the effects of all stores appearing
393 prior to the @code{membar} instruction must be visible to all
394 processors before the effect of any stores following the
395 @code{membar}.  Equivalent to the deprecated @code{stbar} instruction.
396 This corresponds to @code{membar} mmask field bit 3.
397
398 @item
399 @samp{#LoadStore} defines all loads appearing prior to the
400 @code{membar} instruction must have been performed before the effect
401 of any stores following the @code{membar} is visible to any other
402 processor.  This corresponds to @code{membar} mmask field bit 2.
403
404 @item
405 @samp{#StoreLoad} defines that the effects of all stores appearing
406 prior to the @code{membar} instruction must be visible to all
407 processors before loads following the @code{membar} may be performed.
408 This corresponds to @code{membar} mmask field bit 1.
409
410 @item
411 @samp{#LoadLoad} defines that all loads appearing prior to the
412 @code{membar} instruction must have been performed before any loads
413 following the @code{membar} may be performed.  This corresponds to
414 @code{membar} mmask field bit 0.
415
416 @end itemize
417
418 These values can be ored together, for example:
419
420 @example
421 membar #Sync
422 membar #StoreLoad | #LoadLoad
423 membar #StoreLoad | #StoreStore
424 @end example
425
426 The @code{prefetch} and @code{prefetcha} instructions take a prefetch
427 function code.  The following prefetch function code constant
428 mnemonics are available:
429
430 @itemize @bullet
431 @item
432 @samp{#n_reads} requests a prefetch for several reads, and corresponds
433 to a prefetch function code of 0.
434
435 @samp{#one_read} requests a prefetch for one read, and corresponds
436 to a prefetch function code of 1.
437
438 @samp{#n_writes} requests a prefetch for several writes (and possibly
439 reads), and corresponds to a prefetch function code of 2.
440
441 @samp{#one_write} requests a prefetch for one write, and corresponds
442 to a prefetch function code of 3.
443
444 @samp{#page} requests a prefetch page, and corresponds to a prefetch
445 function code of 4.
446
447 @samp{#invalidate} requests a prefetch invalidate, and corresponds to
448 a prefetch function code of 16.
449
450 @samp{#unified} requests a prefetch to the nearest unified cache, and
451 corresponds to a prefetch function code of 17.
452
453 @samp{#n_reads_strong} requests a strong prefetch for several reads,
454 and corresponds to a prefetch function code of 20.
455
456 @samp{#one_read_strong} requests a strong prefetch for one read,
457 and corresponds to a prefetch function code of 21.
458
459 @samp{#n_writes_strong} requests a strong prefetch for several writes,
460 and corresponds to a prefetch function code of 22.
461
462 @samp{#one_write_strong} requests a strong prefetch for one write,
463 and corresponds to a prefetch function code of 23.
464
465 Onle one prefetch code may be specified.  Here are some examples:
466
467 @example
468 prefetch  [%l0 + %l2], #one_read
469 prefetch  [%g2 + 8], #n_writes
470 prefetcha [%g1] 0x8, #unified
471 prefetcha [%o0 + 0x10] %asi, #n_reads
472 @end example
473
474 The actual behavior of a given prefetch function code is processor
475 specific.  If a processor does not implement a given prefetch
476 function code, it will treat the prefetch instruction as a nop.
477
478 For instructions that accept an immediate address space identifier,
479 @code{@value{AS}} provides many mnemonics corresponding to
480 V9 defined as well as UltraSPARC and Niagara extended values.
481 For example, @samp{#ASI_P} and @samp{#ASI_BLK_INIT_QUAD_LDD_AIUS}.
482 See the V9 and processor specific manuals for details.
483
484 @end itemize
485
486 @node Sparc-Relocs
487 @subsection Relocations
488 @cindex Sparc relocations
489 @cindex relocations, Sparc
490
491 ELF relocations are available as defined in the 32-bit and 64-bit
492 Sparc ELF specifications.
493
494 @code{R_SPARC_HI22} is obtained using @samp{%hi} and @code{R_SPARC_LO10}
495 is obtained using @samp{%lo}.  Likewise @code{R_SPARC_HIX22} is
496 obtained from @samp{%hix} and @code{R_SPARC_LOX10} is obtained
497 using @samp{%lox}.  For example:
498
499 @example
500 sethi %hi(symbol), %g1
501 or    %g1, %lo(symbol), %g1
502
503 sethi %hix(symbol), %g1
504 xor   %g1, %lox(symbol), %g1
505 @end example
506
507 These ``high'' mnemonics extract bits 31:10 of their operand,
508 and the ``low'' mnemonics extract bits 9:0 of their operand.
509
510 V9 code model relocations can be requested as follows:
511
512 @itemize @bullet
513 @item
514 @code{R_SPARC_HH22} is requested using @samp{%hh}.  It can
515 also be generated using @samp{%uhi}.
516 @item
517 @code{R_SPARC_HM10} is requested using @samp{%hm}.  It can
518 also be generated using @samp{%ulo}.
519 @item
520 @code{R_SPARC_LM22} is requested using @samp{%lm}.
521
522 @item
523 @code{R_SPARC_H44} is requested using @samp{%h44}.
524 @item
525 @code{R_SPARC_M44} is requested using @samp{%m44}.
526 @item
527 @code{R_SPARC_L44} is requested using @samp{%l44}.
528 @end itemize
529
530 The PC relative relocation @code{R_SPARC_PC22} can be obtained by
531 enclosing an operand inside of @samp{%pc22}.  Likewise, the
532 @code{R_SPARC_PC10} relocation can be obtained using @samp{%pc10}.
533 These are mostly used when assembling PIC code.  For example, the
534 standard PIC sequence on Sparc to get the base of the global offset
535 table, PC relative, into a register, can be performed as:
536
537 @example
538 sethi %pc22(_GLOBAL_OFFSET_TABLE_-4), %l7
539 add   %l7, %pc10(_GLOBAL_OFFSET_TABLE_+4), %l7
540 @end example
541
542 Several relocations exist to allow the link editor to potentially
543 optimize GOT data references.  The @code{R_SPARC_GOTDATA_OP_HIX22}
544 relocation can obtained by enclosing an operand inside of
545 @samp{%gdop_hix22}.  The @code{R_SPARC_GOTDATA_OP_LOX10}
546 relocation can obtained by enclosing an operand inside of
547 @samp{%gdop_lox10}.  Likewise, @code{R_SPARC_GOTDATA_OP} can be
548 obtained by enclosing an operand inside of @samp{%gdop}.
549 For example, assuming the GOT base is in register @code{%l7}:
550
551 @example
552 sethi %gdop_hix22(symbol), %l1
553 xor   %l1, %gdop_lox10(symbol), %l1
554 ld    [%l7 + %l1], %l2, %gdop(symbol)
555 @end example
556
557 There are many relocations that can be requested for access to
558 thread local storage variables.  All of the Sparc TLS mnemonics
559 are supported:
560
561 @itemize @bullet
562 @item
563 @code{R_SPARC_TLS_GD_HI22} is requested using @samp{%tgd_hi22}.
564 @item
565 @code{R_SPARC_TLS_GD_LO10} is requested using @samp{%tgd_lo10}.
566 @item
567 @code{R_SPARC_TLS_GD_ADD} is requested using @samp{%tgd_add}.
568 @item
569 @code{R_SPARC_TLS_GD_CALL} is requested using @samp{%tgd_call}.
570
571 @item
572 @code{R_SPARC_TLS_LDM_HI22} is requested using @samp{%tldm_hi22}.
573 @item
574 @code{R_SPARC_TLS_LDM_LO10} is requested using @samp{%tldm_lo10}.
575 @item
576 @code{R_SPARC_TLS_LDM_ADD} is requested using @samp{%tldm_add}.
577 @item
578 @code{R_SPARC_TLS_LDM_CALL} is requested using @samp{%tldm_call}.
579
580 @item
581 @code{R_SPARC_TLS_LDO_HIX22} is requested using @samp{%tldo_hix22}.
582 @item
583 @code{R_SPARC_TLS_LDO_LOX10} is requested using @samp{%tldo_lox10}.
584 @item
585 @code{R_SPARC_TLS_LDO_ADD} is requested using @samp{%tldo_add}.
586
587 @item
588 @code{R_SPARC_TLS_IE_HI22} is requested using @samp{%tie_hi22}.
589 @item
590 @code{R_SPARC_TLS_IE_LO10} is requested using @samp{%tie_lo10}.
591 @item
592 @code{R_SPARC_TLS_IE_LD} is requested using @samp{%tie_ld}.
593 @item
594 @code{R_SPARC_TLS_IE_LDX} is requested using @samp{%tie_ldx}.
595 @item
596 @code{R_SPARC_TLS_IE_ADD} is requested using @samp{%tie_add}.
597
598 @item
599 @code{R_SPARC_TLS_LE_HIX22} is requested using @samp{%tle_hix22}.
600 @item
601 @code{R_SPARC_TLS_LE_LOX10} is requested using @samp{%tle_lox10}.
602 @end itemize
603
604 Here are some example TLS model sequences.
605
606 First, General Dynamic:
607
608 @example
609 sethi  %tgd_hi22(symbol), %l1
610 add    %l1, %tgd_lo10(symbol), %l1
611 add    %l7, %l1, %o0, %tgd_add(symbol)
612 call   __tls_get_addr, %tgd_call(symbol)
613 nop
614 @end example
615
616 Local Dynamic:
617
618 @example
619 sethi  %tldm_hi22(symbol), %l1
620 add    %l1, %tldm_lo10(symbol), %l1
621 add    %l7, %l1, %o0, %tldm_add(symbol)
622 call   __tls_get_addr, %tldm_call(symbol)
623 nop
624
625 sethi  %tldo_hix22(symbol), %l1
626 xor    %l1, %tldo_lox10(symbol), %l1
627 add    %o0, %l1, %l1, %tldo_add(symbol)
628 @end example
629
630 Initial Exec:
631
632 @example
633 sethi  %tie_hi22(symbol), %l1
634 add    %l1, %tie_lo10(symbol), %l1
635 ld     [%l7 + %l1], %o0, %tie_ld(symbol)
636 add    %g7, %o0, %o0, %tie_add(symbol)
637
638 sethi  %tie_hi22(symbol), %l1
639 add    %l1, %tie_lo10(symbol), %l1
640 ldx    [%l7 + %l1], %o0, %tie_ldx(symbol)
641 add    %g7, %o0, %o0, %tie_add(symbol)
642 @end example
643
644 And finally, Local Exec:
645
646 @example
647 sethi  %tle_hix22(symbol), %l1
648 add    %l1, %tle_lox10(symbol), %l1
649 add    %g7, %l1, %l1
650 @end example
651
652 When assembling for 64-bit, and a secondary constant addend is
653 specified in an address expression that would normally generate
654 an @code{R_SPARC_LO10} relocation, the assembler will emit an
655 @code{R_SPARC_OLO10} instead.
656
657 @node Sparc-Size-Translations
658 @subsection Size Translations
659 @cindex Sparc size translations
660 @cindex size, translations, Sparc
661
662 Often it is desirable to write code in an operand size agnostic
663 manner.  @code{@value{AS}} provides support for this via
664 operand size opcode translations.  Translations are supported
665 for loads, stores, shifts, compare-and-swap atomics, and the
666 @samp{clr} synthetic instruction.
667
668 If generating 32-bit code, @code{@value{AS}} will generate the
669 32-bit opcode.  Whereas if 64-bit code is being generated,
670 the 64-bit opcode will be emitted.  For example @code{ldn}
671 will be transformed into @code{ld} for 32-bit code and
672 @code{ldx} for 64-bit code.
673
674 Here is an example meant to demonstrate all the supported
675 opcode translations:
676
677 @example
678 ldn   [%o0], %o1
679 ldna  [%o0] %asi, %o2
680 stn   %o1, [%o0]
681 stna  %o2, [%o0] %asi
682 slln  %o3, 3, %o3
683 srln  %o4, 8, %o4
684 sran  %o5, 12, %o5
685 casn  [%o0], %o1, %o2
686 casna [%o0] %asi, %o1, %o2
687 clrn  %g1
688 @end example
689
690 In 32-bit mode @code{@value{AS}} will emit:
691
692 @example
693 ld   [%o0], %o1
694 lda  [%o0] %asi, %o2
695 st   %o1, [%o0]
696 sta  %o2, [%o0] %asi
697 sll  %o3, 3, %o3
698 srl  %o4, 8, %o4
699 sra  %o5, 12, %o5
700 cas  [%o0], %o1, %o2
701 casa [%o0] %asi, %o1, %o2
702 clr  %g1
703 @end example
704
705 And in 64-bit mode @code{@value{AS}} will emit:
706
707 @example
708 ldx   [%o0], %o1
709 ldxa  [%o0] %asi, %o2
710 stx   %o1, [%o0]
711 stxa  %o2, [%o0] %asi
712 sllx  %o3, 3, %o3
713 srlx  %o4, 8, %o4
714 srax  %o5, 12, %o5
715 casx  [%o0], %o1, %o2
716 casxa [%o0] %asi, %o1, %o2
717 clrx  %g1
718 @end example
719
720 Finally, the @samp{.nword} translating directive is supported
721 as well.  It is documented in the section on Sparc machine
722 directives.
723
724 @node Sparc-Float
725 @section Floating Point
726
727 @cindex floating point, SPARC (@sc{ieee})
728 @cindex SPARC floating point (@sc{ieee})
729 The Sparc uses @sc{ieee} floating-point numbers.
730
731 @node Sparc-Directives
732 @section Sparc Machine Directives
733
734 @cindex SPARC machine directives
735 @cindex machine directives, SPARC
736 The Sparc version of @code{@value{AS}} supports the following additional
737 machine directives:
738
739 @table @code
740 @cindex @code{align} directive, SPARC
741 @item .align
742 This must be followed by the desired alignment in bytes.
743
744 @cindex @code{common} directive, SPARC
745 @item .common
746 This must be followed by a symbol name, a positive number, and
747 @code{"bss"}.  This behaves somewhat like @code{.comm}, but the
748 syntax is different.
749
750 @cindex @code{half} directive, SPARC
751 @item .half
752 This is functionally identical to @code{.short}.
753
754 @cindex @code{nword} directive, SPARC
755 @item .nword
756 On the Sparc, the @code{.nword} directive produces native word sized value,
757 ie. if assembling with -32 it is equivalent to @code{.word}, if assembling
758 with -64 it is equivalent to @code{.xword}.
759
760 @cindex @code{proc} directive, SPARC
761 @item .proc
762 This directive is ignored.  Any text following it on the same
763 line is also ignored.
764
765 @cindex @code{register} directive, SPARC
766 @item .register
767 This directive declares use of a global application or system register.
768 It must be followed by a register name %g2, %g3, %g6 or %g7, comma and
769 the symbol name for that register.  If symbol name is @code{#scratch},
770 it is a scratch register, if it is @code{#ignore}, it just suppresses any
771 errors about using undeclared global register, but does not emit any
772 information about it into the object file.  This can be useful e.g. if you
773 save the register before use and restore it after.
774
775 @cindex @code{reserve} directive, SPARC
776 @item .reserve
777 This must be followed by a symbol name, a positive number, and
778 @code{"bss"}.  This behaves somewhat like @code{.lcomm}, but the
779 syntax is different.
780
781 @cindex @code{seg} directive, SPARC
782 @item .seg
783 This must be followed by @code{"text"}, @code{"data"}, or
784 @code{"data1"}.  It behaves like @code{.text}, @code{.data}, or
785 @code{.data 1}.
786
787 @cindex @code{skip} directive, SPARC
788 @item .skip
789 This is functionally identical to the @code{.space} directive.
790
791 @cindex @code{word} directive, SPARC
792 @item .word
793 On the Sparc, the @code{.word} directive produces 32 bit values,
794 instead of the 16 bit values it produces on many other machines.
795
796 @cindex @code{xword} directive, SPARC
797 @item .xword
798 On the Sparc V9 processor, the @code{.xword} directive produces
799 64 bit values.
800 @end table