X86-assembly/Instructions/sahf
Jump to navigation
Jump to search
Description
Store AH into flags regsiter:
EFLAGS(SF:ZF:0:AF:0:PF:1:CF) = AH;
Example
If EAX = 001801C7, AH = 01, as shown below:
EAX
|<--------- 32 bits ----------->|
+---+---+---+---+---+---+---+---+
| 0 | 0 | 1 | 8 | 0 | 1 | C | 7 |
+---+---+---+---+---+---+---+---+
AX
|<-- 16 bits -->|
+---+---+---+---+
| 0 | 1 | C | 7 |
+---+---+---+---+
| 8bits | 8bits |
AH AL
The sahf instruction will set EFLAGS as follows:
+---+---+---+---+---+---+---+---+
AH = | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
+---+---+---+---+---+---+---+---+
| | | | | | | \___ CF
| | | | | | \___ reserved
| | | | | \___ PF
| | | | \___ reserved
| | | \___ AF
| | \___ reserved
| \___ ZF
\___ SF