N
nutso fasst
I have a small program that initially clears the display and writes some
text to it, then it tests to determine what CPU it's running on. Later in
the program it hooks INT 08. The program ran OK on Athlon in real mode, but
when run in an NTVDM, the screen wasn't cleared and the initial message
never appeared--console was dead. From debug the program ran OK. If I
removed the code that checked for 386 and 486 it ran OK. And if I didn't
hook INT 08 it ran to completion without crashing.
I found a workaround. Modified CPU check code follows. Note the two STI
instructions. Both were required. If anyone has any ideas why, please
hare. --nf
; check for 386
pushfd
pop eax ; eflags in eax
mov ecx, eax ; in ecx
xor eax, 40000h ; flip AC bit
push eax
popfd ; back on stack
pushfd
pop eax ; back in eax
xor eax, ecx ; can't toggle AC bit?
jz got_cpu_type ; processor=80386
inc cputype
push ecx
popfd ; restore AC bit in eflags
sti ; SET INTERRUPT FLAG
; check for 486
mov eax, ecx ; original eflags
xor eax, 200000h ; flip ID bit
push eax
popfd ; back in eflags
pushfd
pop eax ; back in eax
xor eax, ecx ; can't toggle ID bit?
jz got_cpu_type ; processor=80486
inc cputype ; processor=pentium or later
got_cpu_type:
sti ; SET INTERRUPT FLAG
text to it, then it tests to determine what CPU it's running on. Later in
the program it hooks INT 08. The program ran OK on Athlon in real mode, but
when run in an NTVDM, the screen wasn't cleared and the initial message
never appeared--console was dead. From debug the program ran OK. If I
removed the code that checked for 386 and 486 it ran OK. And if I didn't
hook INT 08 it ran to completion without crashing.
I found a workaround. Modified CPU check code follows. Note the two STI
instructions. Both were required. If anyone has any ideas why, please
hare. --nf
; check for 386
pushfd
pop eax ; eflags in eax
mov ecx, eax ; in ecx
xor eax, 40000h ; flip AC bit
push eax
popfd ; back on stack
pushfd
pop eax ; back in eax
xor eax, ecx ; can't toggle AC bit?
jz got_cpu_type ; processor=80386
inc cputype
push ecx
popfd ; restore AC bit in eflags
sti ; SET INTERRUPT FLAG
; check for 486
mov eax, ecx ; original eflags
xor eax, 200000h ; flip ID bit
push eax
popfd ; back in eflags
pushfd
pop eax ; back in eax
xor eax, ecx ; can't toggle ID bit?
jz got_cpu_type ; processor=80486
inc cputype ; processor=pentium or later
got_cpu_type:
sti ; SET INTERRUPT FLAG