Skip to content

Commit 82aad01

Browse files
chorman0773joshtriplett
authored andcommitted
Sort lists, add syntax control directives
1 parent 9de9c05 commit 82aad01

File tree

1 file changed

+39
-40
lines changed

1 file changed

+39
-40
lines changed

src/inline-assembly.md

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ On x86, the `.intel_syntax noprefix` mode of GAS is used by default.
8787
On ARM, the `.syntax unified` mode is used.
8888
These targets impose an additional restriction on the assembly code: any assembler state (e.g. the current section which can be changed with `.section`) must be restored to its original value at the end of the asm string.
8989
Assembly code that does not conform to the GAS syntax will result in assembler-specific behavior.
90-
Further constraints on the directives used by inline assembly are indicated by [Directives Support](#directives-support).
90+
Further constraints on the directives used by the assembly are indicated by [Directives Support](#directives-support).
9191

9292
[format-syntax]: ../std/fmt/index.html#syntax
9393
[rfc-2795]: https://github.com/rust-lang/rfcs/pull/2795
@@ -481,70 +481,65 @@ To avoid undefined behavior, these rules must be followed when using function-sc
481481
482482
### Directives Support
483483

484-
Inline assembly supports a subset of the directives supported by both GNU AS and LLVM's internal assembler, given as follows.
484+
Inline ASM supports a subset of the directives supported by both GNU AS and LLVM's internal assembler, given as follows.
485485
The result of using other directives is assembler-specific (and may cause an error, or may be accepted as-is).
486486

487-
If inline assembly includes any "stateful" directive that modifies how subsequent assembly is processed, the block must undo the effects of any such directives before the inline assembly ends.
488-
489487
The following directives are guaranteed to be supported by the assembler:
490488

491489

492490
- `.2byte`
493491
- `.4byte`
494492
- `.8byte`
495-
- `.byte`
496-
- `.short`
497-
- `.word`
498-
- `.long`
499-
- `.quad`
500-
- `.float`
501-
- `.double`
502-
- `.octa`
503-
- `.sleb128`
504-
- `.uleb128`
493+
- `.align`
505494
- `.ascii`
506495
- `.asciz`
507-
- `.string`
508-
- `.skip`
509-
- `.space`
510496
- `.balign`
511497
- `.balignl`
512498
- `.balignw`
513499
- `.balign`
514500
- `.balignl`
515501
- `.balignw`
516-
- `.fill`
517-
- `.section`
518-
- `.pushsection`
519-
- `.popsection`
520-
- `.subsection`
521-
- `.text`
522502
- `.bss`
503+
- `.byte`
504+
- `.comm`
523505
- `.data`
524506
- `.def`
507+
- `.double`
525508
- `.endef`
526-
- `.scl`
527-
- `.comm`
528-
- `.lcomm`
529-
- `.option`
530509
- `.equ`
531510
- `.equiv`
532511
- `.eqv`
533-
- `.set`
534-
- `.align`
512+
- `.fill`
513+
- `.float`
514+
- `.lcomm`
535515
- `.inst`
516+
- `.long`
517+
- `.octa`
518+
- `.option`
536519
- `.p2align`
537-
- `.bundle_align_mode`
538-
- `.bundle_lock`
539-
- `.bundle_unlock`
540-
- `.symver`
520+
- `.pushsection`
521+
- `.popsection`
522+
- `.quad`
523+
- `.scl`
524+
- `.section`
525+
- `.set`
526+
- `.short`
527+
- `.skip`
528+
- `.sleb128`
529+
- `.space`
530+
- `.string`
531+
- `.text`
532+
- `.uleb128`
533+
- `.word`
534+
535+
541536

542537
The following directives are guaranteed to be supported for `global_asm` only:
543538

544539
- `.alt_entry`
545-
- `.private_extern`
546540
- `.globl`
547541
- `.global`
542+
- `.private_extern`
548543
- `.size`
549544
- `.type`
550545

@@ -592,18 +587,21 @@ On targets with structured exception Handling, the following additional directiv
592587
- `.seh_stackalloc`
593588

594589

595-
##### x86 (32-bit and 64-bit)
590+
##### x86
596591

597-
On x86 targets, both 32-bit and 64-bit, the following additional directives are guaranteed to be supported:
592+
On x86, the following additional directives are guaranteed to be supported:
593+
- `.att_syntax`
594+
- `.intel_syntax`
598595
- `.nops`
599596

600-
On x86 for `global_asm!` only, the following additional directives are guaranteed to be supported (it is unspecified whether `.code16` or `.code32` are supported for `asm!()`):
597+
Use of the `.att_syntax` and `.intel_syntax` with no parameters is supported, but the syntax must be restored to the option at entry (`.intel_syntax` without the `att_syntax` asm option, or `.att_syntax` with that option) or the behaviour is undefined (the output of the compiler may be corrupted as a result). Use of `.att_syntax` and `.intel_syntax` with an option (such as `.intel_syntax prefix` or `.att_syntax noprefix`) is unsupported and results in assembler-dependant behaviour.
601598

599+
On x86 for `global_asm!` only, the following additional directives are guaranteed to be supported:
602600
- `.code16`
603601
- `.code32`
604602

605603

606-
##### ARM
604+
##### ARM (32-bit only)
607605

608606
On ARM for `global_asm!` only, the following additional directives are guaranteed to be supported:
609607

@@ -614,8 +612,9 @@ On ARM for `global_asm!` only, the following additional directives are guarantee
614612

615613
On ARM, the following additional directives are guaranteed to be supported:
616614

615+
- `.even`
617616
- `.fnstart`
618617
- `.fnend`
619-
- `.save`
620618
- `.movsp`
621-
- `.even`
619+
- `.save`
620+

0 commit comments

Comments
 (0)