Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

SSE instructions in DOS programs? (Developers)

posted by Rugxulo(R) Homepage, Usono, 02.01.2019, 10:08

> Hi!

Felichan Novjaron!

> What is the recomended way how to obtain whether I can use the SSE
> instructions?
> First step is clear - use the CPUID.

But check if CPUID is supported first. (What clone cpu was it that needed it manually enabled?) But to do that assumes 386, so you have to check for that, too. And even that is messy, so check for 286 first. No, I'm not kidding.

> But what about test whether the SSE are supported by the OS?

  fxsave [xmm_save]
  mov dword ptr [xmm_save+160],0x45443043   # 'C0DE'
  fxrstor [xmm_save]
  mov dword ptr [xmm_save+160],0x44303044   # 'D00D'
  fxsave [xmm_save]
  cmp dword ptr [xmm_save+160],0x45443043   # 'C0DE'
  mov eax,0
  jnz _sse_supported_bye
  inc al                     # if OSFXSR not turned on, XMM* are not saved

> Sure, I can just include some DPMI server which enables (supports) the SSE
> (cwsdpmi r7) but what about situation when already other DPMI server is
> running?

Causeway (CWSTUB) 4.x, DOS/32A 9.1.2, HDPMI32, and CWSDPMI (r5 2008 or later) all enable it for you.

It's because you're not supposed to use it if the OS can't handle it. OXFXSR means save extended FPU state across task switches. FXSAVE/FXRSTOR actually first appeared in late model P2s, and it's faster than the old way.

> Or somebody uses my program under Win95? (which does not have the
> SSE support)

Win95 predates it (SSE1 was 1998/2001, and SSE2 was 2000/2003), but I forget exactly when (Win95 OSR2?) that it was later supported. I'm sure you can just run some simple tool (in DOS, via AUTOEXEC) before Win95 starts up, no?

> Internet says that it is enough to test the 9.bit and 10.bit in the CR4
> register. But "MOV CR4,AX" is a privileged instruction. So - what to do?

Yes, that was the problem (for me), CWSDPMI r5 (2000 or 2002) was ring 3 by default, so I couldn't manually enable it (easily). Plus, even the weaker ring 0 version didn't support swapping.

Obviously you have to enable it before switching away from ring 0. I'd almost wonder why this kind of thing isn't in the FreeDOS kernel proper, but sadly it's too rare for most DOS programmers to care about. I'm glad CWS was wise enough to add support for it.

Here's some few other links I posted on FASM's forum a while back. (I'm no expert, of course.)

P.S. It's all for naught. Most mainstream software has, for years, blindly assumed and forced SSE2 on everyone. "Most" people have it already. Many "obsolete" 32-bit (IA-32) projects have been abandoned as well in lieu of AMD64. And AVX-512 will assimilate us all. Resistance is futile.


Complete thread:

Back to the forum
Board view  Mix view
15891 Postings in 1469 Threads, 269 registered users, 97 users online (0 registered, 97 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum