x86 EFLAGS: Difference between revisions

From Thought dump
Jump to navigation Jump to search
→‎C macro constants: fix constant vals
→‎EFLAGS table: fix bit offsets in the table
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:
! Abbreviation
! Abbreviation
|-
|-
! 1
! 0
| S
| S
| Carry Flag
| Carry Flag
| <code>CF</code>
| <code>CF</code>
|-
|-  
! 2
! 1
| 0
| 0  
| Always clear
| Always clear  
| <code>rsvd_2</code><ref>For reserved flags, name from the code below is shown.</ref>
| <code>rsvd_2</code><ref>For reserved flags, name from the code below is shown.</ref>
|-
|-  
! 3
! 2
| S
| S  
| Parity Flag
| Parity Flag  
| <code>PF</code>
| <code>PF</code>
|-
|-  
! 4
! 3
| 1
| 1  
| Always set
| Always set  
| <code>rsvd_4</code>
| <code>rsvd_4</code>
|-
|-  
! 5
! 4
| S
| S  
| Auxiliary Carry Flag
| Auxiliary Carry Flag  
| <code>AF</code>
| <code>AF</code>
|-
|-  
! 6
! 5
| 1
| 1  
| Always set
| Always set  
| <code>rsvd_6</code>
| <code>rsvd_6</code>
|-
|-  
! 7
! 6
| S
| S  
| Zero Flag
| Zero Flag  
| <code>ZF</code>
| <code>ZF</code>
|-
|-  
! 8
! 7
| S
| S  
| Sign Flag
| Sign Flag  
| <code>SF</code>
| <code>SF</code>
|-
|-  
! 9
! 8
| X
| X  
| Trap Flag
| Trap Flag  
| <code>TF</code>
| <code>TF</code>
|-
|-  
! 10
! 9
| X
| X  
| Interrupt Enable Flag
| Interrupt Enable Flag  
| <code>IF</code>
| <code>IF</code>
|-
|-  
! 11
! 10
| C
| C  
| Direction Flag
| Direction Flag  
| <code>DF</code>
| <code>DF</code>
|-
|-  
! 12
! 11
| S
| S  
| Overflow Flag
| Overflow Flag  
| <code>OF</code>
| <code>OF</code>
|-
! 12
|rowspan=2| X
|rowspan=2| I/O Privilege Level
|rowspan=2| <code>IOPL</code>
|-
|-
! 13
! 13
| X
|-  
| I/O Privilege Level
! 14  
| <code>IOPL</code>
| X  
|-
| Nested Task  
! 14
| X
| Nested Task
| <code>NT</code>
| <code>NT</code>
|-
|-  
! 15
! 15  
| 0
| 0  
| Always clear
| Always clear  
| <code>rsvd_15</code>
| <code>rsvd_15</code>
|-
|-  
! 16
! 16  
| X
| X  
| Resume Flag
| Resume Flag  
| <code>RF</code>
| <code>RF</code>
|-
|-  
! 17
! 17  
| X
| X  
| Virtual-8086 Mode
| Virtual-8086 Mode  
| <code>VM</code>
| <code>VM</code>
|-
|-  
! 18
! 18  
| X
| X  
| Alignment Check / Access Control
| Alignment Check / Access Control  
| <code>AC</code>
| <code>AC</code>
|-
|-  
! 19
! 19  
| X
| X  
| Virtual Interrupt Flag
| Virtual Interrupt Flag  
| <code>VIF</code>
| <code>VIF</code>
|-
|-  
! 20
! 20  
| X
| X  
| Virtual Interrupt Pending
| Virtual Interrupt Pending  
| <code>VIP</code>
| <code>VIP</code>
|-
|-  
! 21
! 21  
| X
| X  
| ID Flag
| ID Flag  
| <code>ID</code>
| <code>ID</code>
|}
|}
Line 128: Line 130:
#define X86_EFLAGS_OF            11 /* Overflow Flag [S]                    */
#define X86_EFLAGS_OF            11 /* Overflow Flag [S]                    */
#define X86_EFLAGS_IOPL          12 /* I/O Privilege Level [X]              */
#define X86_EFLAGS_IOPL          12 /* I/O Privilege Level [X]              */
#define X86_EFLAGS_IOPL_LO      12 /* I/O Privilege Level low bit. [X]     */
#define X86_EFLAGS_IOPL_LO      12 /* I/O Privilege Level low bit [X]     */
#define X86_EFLAGS_IOPL_HI      13 /* I/O Privilege Level high bit. [X]   */
#define X86_EFLAGS_IOPL_HI      13 /* I/O Privilege Level high bit [X]     */
#define X86_EFLAGS_NT            14 /* Nested Task [X]                      */
#define X86_EFLAGS_NT            14 /* Nested Task [X]                      */
#define X86_EFLAGS_rsvd_15      15 /* Always clear [0]                    */
#define X86_EFLAGS_rsvd_15      15 /* Always clear [0]                    */

Latest revision as of 17:21, 22 March 2025

EFLAGS table

Bit Type
/val.[1]
Name Abbreviation
0 S Carry Flag CF
1 0 Always clear rsvd_2[2]
2 S Parity Flag PF
3 1 Always set rsvd_4
4 S Auxiliary Carry Flag AF
5 1 Always set rsvd_6
6 S Zero Flag ZF
7 S Sign Flag SF
8 X Trap Flag TF
9 X Interrupt Enable Flag IF
10 C Direction Flag DF
11 S Overflow Flag OF
12 X I/O Privilege Level IOPL
13
14 X Nested Task NT
15 0 Always clear rsvd_15
16 X Resume Flag RF
17 X Virtual-8086 Mode VM
18 X Alignment Check / Access Control AC
19 X Virtual Interrupt Flag VIF
20 X Virtual Interrupt Pending VIP
21 X ID Flag ID

C macro constants

#define X86_EFLAGS_CF             0 /* Carry Flag [S]                       */
#define X86_EFLAGS_rsvd_2         1 /* Always clear [0]                     */
#define X86_EFLAGS_PF             2 /* Parity Flag [S]                      */
#define X86_EFLAGS_rsvd_4         3 /* Always set [1]                       */
#define X86_EFLAGS_AF             4 /* Auxiliary Carry Flag [S]             */
#define X86_EFLAGS_rsvd_6         5 /* Always set [1]                       */
#define X86_EFLAGS_ZF             6 /* Zero Flag [S]                        */
#define X86_EFLAGS_SF             7 /* Sign Flag [S]                        */
#define X86_EFLAGS_TF             8 /* Trap Flag [X]                        */
#define X86_EFLAGS_IF             9 /* Interrupt Enable Flag [X]            */
#define X86_EFLAGS_DF            10 /* Direction Flag [C]                   */
#define X86_EFLAGS_OF            11 /* Overflow Flag [S]                    */
#define X86_EFLAGS_IOPL          12 /* I/O Privilege Level [X]              */
#define X86_EFLAGS_IOPL_LO       12 /* I/O Privilege Level low bit [X]      */
#define X86_EFLAGS_IOPL_HI       13 /* I/O Privilege Level high bit [X]     */
#define X86_EFLAGS_NT            14 /* Nested Task [X]                      */
#define X86_EFLAGS_rsvd_15       15 /* Always clear [0]                     */
#define X86_EFLAGS_RF            16 /* Resume Flag [X]                      */
#define X86_EFLAGS_VM            17 /* Virtual-8086 Mode [X]                */
#define X86_EFLAGS_AC            18 /* Alignment Check / Access Control [X] */
#define X86_EFLAGS_VIF           19 /* Virtual Interrupt Flag [X]           */
#define X86_EFLAGS_VIP           20 /* Virtual Interrupt Pending [X]        */
#define X86_EFLAGS_ID            21 /* ID Flag [X]                          */
  1. Indicated whether this is a status (s), control (c), or system (x) flag. For reserved flags, its value is shown.
  2. For reserved flags, name from the code below is shown.