How to read and write x86 flags registers directly?

前端 未结 6 893
执笔经年
执笔经年 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:50

    If you need only the lower byte of the flags register (which contains SF,ZF,AF,PF,CF), then there is the odd but convenient instruction LAHF (ha ha), which loads the bottom 8 bits of the flags register into AH, and its counterpart SAHF to store AH into flags.

    For the carry flag specifically, x86 offers CLC, STC and CMC, to clear, set, and complement the carry flag, respectively.

提交回复
热议问题