Author Topic: EFLAGS  (Read 7834 times)

M. David Johnson

  • Guest
EFLAGS
« on: October 05, 2005, 11:51:26 PM »
In order to check if the CPUID instruction is valid on any given machine, I need to check the alterability of the 21st bit of the EFLAGS register, e.g.:

btc EFLAGS

but NASM doesn't seem to recognize EFLAGS as a register and reports:

symbol 'EFLAGS' undefined.

???

M. David Johnson
mdjohnson@worldnet.att.net

M. David Johnson

  • Guest
Re: EFLAGS
« Reply #1 on: October 05, 2005, 11:53:04 PM »
Sorry, that's:

btc EFLAGS,21

nasm64developer

  • Guest
Re: EFLAGS
« Reply #2 on: October 06, 2005, 02:18:38 AM »
The first operand of BTC must be r/m, i.e. either
a memory location or a general purpose register.

EFLAGS is not a general-purpose register. Thus it
cannot be used with BTC. (Hence the NASM error.)

You will need to use PUSHFD/POPFD to move EFLAGS
from/to a general purpose register via the stack.

Note that PUSHFD/POPFD are subject to privilege
checks; application-level code may or may not be
allowed to execute them; it depends on your OS.

Last but not least, note that toggling EFLAGS.ID
is not a 100% reliable means for determining if
a processor supports CPUID. For example, certain
NexGen processors supported the instruction but
not the ID bit, and certain Cyrix processors did
require you to explicitly enable the instruction.

M. David Johnson

  • Guest
Re: EFLAGS
« Reply #3 on: October 06, 2005, 01:50:00 PM »
Thanks. I'll apply the PUSHFD/POPFD mechanism and see if it works under WinXP.

Meanwhile, could you please point me to a workaround for the NextGen/Cyrix/etc. non-recognition of the ID bit?