CPUID and trap problem

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
whyme_t

CPUID and trap problem

Post by whyme_t »

I'm having some problems with the EFLAGS ID-bit method of detecting if a cpu has the cpuid instruction.

I pushfd, store the flags, switch bit 21, push it on the stack, and popfd, and this works ok.

But when I pushfd again to compare the bit 21 with the stored value, It Reboots (Real hardware) or 3rd Exception CPU (Bochs) (interrupts are disabled, I think it's a trap)

But If i pushfd and popfd the second time with no code inbetween, there is no problem.

What am I doing wrong?
whyme_t

Re:CPUID and trap problem

Post by whyme_t »

When you've been looking at code for a few hours trying to fix something, sometimes you just need a quick break :)

By the time I'd posted and gone back to my code, I saw the problem. I'd poped the eflags into eax, and hadn't pushed eax back on, between the second pushfd and popfd.
Post Reply