标志寄存器 - 我们可以读取或直接与他们写? [英] Flags registers - Can we read or write them directly?

查看:410
本文介绍了标志寄存器 - 我们可以读取或直接与他们写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我读过,好像有9种不同的标志。是否有可能直接读取/修改呢?我知道我可以知道,例如,如果零标志做了CMP / JMP指令后确定,但我问是否有可能做这样的事

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 a cmp/jmp instruction, but I'm asking if it's possible to do something like

mov eax, flags

什么的。

此外,对于书面方式,才有可能通过手工设置它们?

Also, for writting, is it possible to set them by hand?

推荐答案

某些标志,可以设置或直接与特定的指令清除:

Some flags can be set or cleared directly with specific instructions:


  • CLC ,的STC 和的CMC :清晰,设置,并补充进位标志

  • CLI 并的STI :清晰,设置中断标志(应该自动完成)

  • CLD 并的STD :明确并设置方向标志

  • CLC, STC, and CMC: clear, set, and complement the carry flag
  • CLI and STI: clear and set the interrupt flag (which should be done atomically)
  • CLD and STD: clear and set the direction flag

有关读写的标志,零,辅助进,奇偶校验,并进行标记,你可以使用的 LAHF 低8位(这5个标志加3不确定位)加载到AH寄存器,并且可以使用的 SAHF 存储从AH这些值回标志寄存器。

For reading and writing the sign, zero, auxiliary carry, parity, and carry flags, you can use LAHF to load the lower 8 bits (those 5 flags plus 3 indeterminate bits) into the AH register, and you can use SAHF to store those values from AH back into the flags register.

您也可以使用 PUSHF 指示标志推到栈,读取和修改他们在堆栈上,然后使用 POPF 指令将它们存储回到标志寄存器。

You can also use the PUSHF instruction to push the flags onto the stack, read and modify them on the stack, and then use the POPF instruction to store them back into the flags register.

请注意,你不能设定POPF虚拟机和RF标志 - 他们保留自己的previous值。同样的,你只能在特权级别0执行时,在权限级别至少为特权的I / O特权级别执行时更改I / O特权级别,并且中断标志只能被改变。

Note that you cannot set the VM and RF flags with POPF -- they retain their previous values. Similarly, you can only change the I/O privilege level when executing at privilege level 0, and the interrupt flag can only be changed when executing at a privilege level at least as privileged as the I/O privilege level.

这篇关于标志寄存器 - 我们可以读取或直接与他们写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆