Skip to content

Commit 3633849

Browse files
committed
Clarify rules regarding the x86 direction flag
1 parent 89f917e commit 3633849

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

text/0000-inline-asm.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,6 @@ unsafe fn foo(mut a: i32, b: i32) -> (i32, i32)
801801
- These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:
802802
- x86
803803
- Status flags in `EFLAGS` (CF, PF, AF, ZF, SF, OF).
804-
- Direction flag in `EFLAGS` (DF).
805804
- Floating-point status word (all).
806805
- Floating-point exception flags in `MXCSR` (PE, UE, OE, ZE, DE, IE).
807806
- ARM
@@ -816,6 +815,8 @@ unsafe fn foo(mut a: i32, b: i32) -> (i32, i32)
816815
- Floating-point status (`FPSR` register).
817816
- RISC-V
818817
- Floating-point exception flags in `fcsr` (`fflags`).
818+
- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.
819+
- Behavior is undefined if the direction flag is set on exiting an asm block.
819820
- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.
820821
- This means that `asm!` blocks that never return (even if not marked `noreturn`) don't need to preserve these registers.
821822
- When returning to a different `asm!` block than you entered (e.g. for context switching), these registers must contain the value they had upon entering the `asm!` block that you are *exiting*.

0 commit comments

Comments
 (0)