How to read and write x86 flags registers directly?

前端 未结 6 892
执笔经年
执笔经年 2020-11-29 05:07

From what I\'ve read, seems like there are 9 different flags. Is it possible to read/change them directly? I know I can know for example if the zero flag is set after doing

6条回答
  •  不知归路
    2020-11-29 05:56

    SETcc

    This instruction family is another way to observe some flags / combination of flags.

    It sets the value of a byte based on the individual FLAGS.

    E.g., for CF:

    stc
    setc al
    ; al == 1
    
    clc
    setc al
    ; al == 0
    

    Runnable GitHub upstream with assertions.

    Jcc

    This instruction family is of course another possibility for certain flags, and could be used to implement SETcc:

    jc set
    mov al, 0
    jmp end
    set:
    mov al, 1
    end:
    

    Runnable GitHub upstream with assertions.

提交回复
热议问题