The CMC instruction
The CMC (Complement Carry) instruction is used to invert the state of the carry flag. If the carry flag (CY) is currently set to 1, it will be reset to 0 after the CMC instruction is executed. Conversely, if the carry flag is currently set to 0, it will be set to 1.
The CMC instruction format
| Instruction | Description |
|---|---|
| CMC | Inverts the carry flag CY. |
Usage example
; Author: Evgeny Sergeevich Dovgopolov main: stc ; Set the carry flag to 1 cmc ; Invert the carry flag hlt ; Stop program execution
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
S
NoZ
NoAC
NoP
NoCY
Yes