From: Skybuck Flying on
Hello,

My questions are:

Q1: How much x86 instruction set usage-difference is there between windows
95 and windows xp ?

As far as I know the x86 instruction set can be divide into two parts:

Part 1. Operating system specific instructions and registers for
kernel-space/mode/world.

Part 2. Application specific instructions and registers for
user-space/mode/world.

I am pretty familiar with user-space/mode/world, not so familiar with
kernel-space/mode/world.

Differences which I am already aware of:
Multi Media Extension/Streaming Extension(s) (MMX, SSE, SSE2, etc) (used by
applications, codecs, maybe os too ?)
x64 (64 bit extension) (my questions are about x86 though...)

Q2: Has the x86 instruction set received any major or minor extension(s) for
operating system usage (kernel-space) through the years ?

(Maybe new instructions ?, maybe new registers ?)

Bye,
Skybuck.
















From: Alexei A. Frounze on
On Mar 24, 9:28 pm, "Skybuck Flying" <IntoTheFut...(a)hotmail.com>
wrote:
> Hello,
>
> My questions are:
>
> Q1: How much x86 instruction set usage-difference is there between windows
> 95 and windows xp ?
>
> As far as I know the x86 instruction set can be divide into two parts:
>
> Part 1. Operating system specific instructions and registers for
> kernel-space/mode/world.
>
> Part 2. Application specific instructions and registers for
> user-space/mode/world.
>
> I am pretty familiar with user-space/mode/world, not so familiar with
> kernel-space/mode/world.
>
> Differences which I am already aware of:
> Multi Media Extension/Streaming Extension(s) (MMX, SSE, SSE2, etc) (used by
> applications, codecs, maybe os too ?)
> x64 (64 bit extension) (my questions are about x86 though...)
>
> Q2: Has the x86 instruction set received any major or minor extension(s) for
> operating system usage (kernel-space) through the years ?
>
> (Maybe new instructions ?, maybe new registers ?)
>
> Bye,
>   Skybuck.

System instructions should not be of a concern to you unless you're
writing a driver that executes in the kernel mode. You simply won't be
able to execute them in user mode apps (and I suppose this is the
case).

Now, new non-system instructions that don't come in with new CPU
registers or special state structures (e.g. MMX/XMM regs, MXCSR)
should work equally well under either system. Think of POPCNT, for
example. It works with the same general purpose regs and as long it's
supported by the CPU (check with CPUID), you can use it. But you're
out of luck with XMM under Win9x/2K because the OS isn't gonna save
and restore them as part of a context switch (switch between threads)
and even if you can execute those SSE instructions, as soon as two
threads start executing them concurrently, the XMM reg state will get
trashed.

This is the idea. Look at the new registers and new instructions that
have appeared since win9x days to figure out what's safe to use and
what's not.

Also, there might be some new CPU features (including instructions)
that get enabled through writing something to CRs and MSRs. If those
aren't enabled by default or the old OS disables them by writing 0's
to then-reserved bit fields, you won't be able to use those features/
instructions in user mode apps. You'll need a dedicated kernel mode
driver to change CRs/MSRs to overcome this.

HTH,
Alex
From: Rugxulo on
Hi,

On Mar 25, 1:15 am, "Alexei A. Frounze" <alexfrun...(a)gmail.com> wrote:
> On Mar 24, 9:28 pm, "Skybuck Flying" <IntoTheFut...(a)hotmail.com>
> wrote:
>
> > Q2: Has the x86 instruction set received any major or minor extension(s) for
> > operating system usage (kernel-space) through the years ?
>
> > (Maybe new instructions ?, maybe new registers ?)
>
> Now, new non-system instructions that don't come in with new CPU
> registers or special state structures (e.g. MMX/XMM regs, MXCSR)
> should work equally well under either system. Think of POPCNT, for
> example. It works with the same general purpose regs and as long it's
> supported by the CPU (check with CPUID), you can use it.

Be sure to also check if CPUID is supported before using it! ;-)

> But you're
> out of luck with XMM under Win9x/2K because the OS isn't gonna save
> and restore them as part of a context switch (switch between threads)
> and even if you can execute those SSE instructions, as soon as two
> threads start executing them concurrently, the XMM reg state will get
> trashed.

I don't know first-hand, but from what I've read, the following all
support SSE state saving (FXSAVE/FXRSTOR): Win95 OSR2, Win98, WinNT
4.0 SP4 + driver, WinNT 5.0 beta 2, or newer. As you probably know,
WinNT 5 was officially renamed to Win2k.

Not sure what Linux version introduced support, 2.2 or 2.4, somewhere
in there.
EDIT: Seems old patches for 2.2.5 and 2.2.12 are available at
http://sourceware.org/gdb/papers/linux/linux-sse.html .

FXSAVE/FXRSTOR are meant to be faster at saving FPU/XMM and were
actually introduced in late model Pentium II cpus. Of course, SSE1
only came with Pentium III (or Athlon XP).

P.S. Is the original poster in this thread actually running Win95
somewhere or just asking hypothetically?
From: Alexei A. Frounze on
On Mar 25, 12:54 pm, Rugxulo <rugx...(a)gmail.com> wrote:
> Hi,
>
> On Mar 25, 1:15 am, "Alexei A. Frounze" <alexfrun...(a)gmail.com> wrote:
>
> > On Mar 24, 9:28 pm, "Skybuck Flying" <IntoTheFut...(a)hotmail.com>
> > wrote:
>
> > > Q2: Has the x86 instruction set received any major or minor extension(s) for
> > > operating system usage (kernel-space) through the years ?
>
> > > (Maybe new instructions ?, maybe new registers ?)
>
> > Now, new non-system instructions that don't come in with new CPU
> > registers or special state structures (e.g. MMX/XMM regs, MXCSR)
> > should work equally well under either system. Think of POPCNT, for
> > example. It works with the same general purpose regs and as long it's
> > supported by the CPU (check with CPUID), you can use it.
>
> Be sure to also check if CPUID is supported before using it!   ;-)

Must be on all Pentium class CPUs. Anyone still has 80486? :)

> > But you're
> > out of luck with XMM under Win9x/2K because the OS isn't gonna save
> > and restore them as part of a context switch (switch between threads)
> > and even if you can execute those SSE instructions, as soon as two
> > threads start executing them concurrently, the XMM reg state will get
> > trashed.
>
> I don't know first-hand, but from what I've read, the following all
> support SSE state saving (FXSAVE/FXRSTOR):   Win95 OSR2, Win98, WinNT
> 4.0 SP4 + driver, WinNT 5.0 beta 2, or newer. As you probably know,
> WinNT 5 was officially renamed to Win2k.
>
> Not sure what Linux version introduced support, 2.2 or 2.4, somewhere
> in there.
> EDIT: Seems old patches for 2.2.5 and 2.2.12 are available athttp://sourceware.org/gdb/papers/linux/linux-sse.html.
>
> FXSAVE/FXRSTOR are meant to be faster at saving FPU/XMM and were
> actually introduced in late model Pentium II cpus. Of course, SSE1
> only came with Pentium III (or Athlon XP).

I might be wrong and you right. I've rarely needed to use this
instruction subset, so I don't know/remember all the historical
details.

Alex
From: Rugxulo on
Hi,

On Mar 26, 12:45 am, "Alexei A. Frounze" <alexfrun...(a)gmail.com>
wrote:
> On Mar 25, 12:54 pm, Rugxulo <rugx...(a)gmail.com> wrote:
>
> > Be sure to also check if CPUID is supported before using it!   ;-)
>
> Must be on all Pentium class CPUs. Anyone still has 80486? :)

Yes, but I don't use it (CMOS dead, keyboard hard to use). Besides,
honestly, it's really slow (duh)! ;-)

> > > But you're out of luck with XMM under Win9x/2K because the OS isn't
> > > gonna save and restore them as part of a context switch (switch between threads)
>
> > I don't know first-hand, but from what I've read, the following all
> > support SSE state saving (FXSAVE/FXRSTOR):   Win95 OSR2, Win98, WinNT
> > 4.0 SP4 + driver, WinNT 5.0 beta 2, or newer. As you probably know,
> > WinNT 5 was officially renamed to Win2k.
>
> I might be wrong and you right. I've rarely needed to use this
> instruction subset, so I don't know/remember all the historical
> details.

It's only important if you care about extreme compatibility. Mainly, I
just wanted it to be clear that even Win2k (which is still somewhat
supported) isn't off limits!