FPU Emulator

General Discussion, STOS.

Moderator: troed

User avatar
agranlund
Posts: 777
Joined: Sun Aug 18, 2019 10:43 pm
Location: Sweden
Contact:

Re: FPU Emulator

Post by agranlund »

frank.lukas wrote: Sun Jul 10, 2022 4:07 pm CPUFPU Program also doesn't show the FPU just like MiNT/XaAES do ...

CPUFPU.PRG.zip
Thanks! Indeed, I see the same here with that program.
I'll take a look what that program does for detection at some point :)

I'm guessing it's not reading the _FPU cookie and perhaps the emulation is not reacting properly to whatever it does to detect it (I wouldn't know.. I can't claim to understand what the emulation code is doing. I basically just ripped it out of the NetBSD kernel, got rid of NetBSD dependencies, and then made the necessary modifications and glue code so it could interface with our operating system instead)


Does it work with something known to work though?
The _FPU cookie should be $00040000 after running fpemu.prg

I tested Gembench, Nembench, Kronos, "FPUTEST.TOS", "FPUREC.TOS" here. And my own little test program of course that was built for 68020-60.
User avatar
agranlund
Posts: 777
Joined: Sun Aug 18, 2019 10:43 pm
Location: Sweden
Contact:

Re: FPU Emulator

Post by agranlund »

Steve wrote: Sun Jul 10, 2022 3:49 pm I posted this thread to the freemint mailing list so probably @mikro might chime in with freemint specific peculiars. Either way it doesn't really matter if the xaaes reports show an FPU or not, as long as console programs that check for an FPU work that's the main thing.
Yeah that's pretty much all I wanted it for anyway.

But still, if there are some easy fixes to problems then it could be worth fixing them.
Or rather, if there are some fun fixes or additions then it's always worth it for me. When they're not fun then yeah, I don't really care since I don't want my hobby to start feeling like a job :lol:

I have a feeling my interest for this particular sidetrack is going to fade off pretty quickly but I'll post the sources on Github so they're not lost and anyone who's interested could take it over or help out if there are additional issues.
User avatar
agranlund
Posts: 777
Joined: Sun Aug 18, 2019 10:43 pm
Location: Sweden
Contact:

Re: FPU Emulator

Post by agranlund »

Hmmn, I realised if you try to detect FPU the way you normally detect hardware by temporarily replacing the relevant error vector and see if it hits, then you'll think there is no FPU - it is going to hit the detectors temporary LineF handler.
I bet this is what's going on for programs that aren't simply looking at the cookies.

I don't know if there is a good way to solve that?
The only ways I can think of are either too little, or too much overkill for an fpu emulator..

Might have to live with only things asking the cookies getting a "yes it exists" unless someone clever has a good idea how to solve it :)


Not quite enough:
- replace the Setexc function.
You normally do these kinds of detections in assembly, and it's more code to use Setexc compared to setting the vector yourself.
Since coders are lazy, it'll probably be a bit hit and miss if anyone's actually using Setexc or not for that purpose (I certainly don't in hardware detect scenarios)

Too heavy handed:
- Light virtualisation of the vectors by moving the VBR.
This only works if no one are checking the VBR register to see if someone moved them away from $0.
As it happens, no Atari software nor the OS does so it would work but it feels too intrusive for a simple FPU emulator.
(This is how BasiliskII for Atari can get away with not having to do full-on virtual machines. Both Atari and Mac assumes the vectors always stay at 0)

Completely nuts:
- Take total control of the computer by locking everything else, including the OS, inside a fake and virtual supervisor mode..
That might be interesting for some kind of malicious software but maybe not so much for this :lol:
User avatar
stephen_usher
Posts: 5583
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: FPU Emulator

Post by stephen_usher »

agranlund wrote: Sun Jul 10, 2022 9:23 pm Completely nuts:
- Take total control of the computer by locking everything else, including the OS, inside a fake and virtual supervisor mode..
That might be interesting for some kind of malicious software but maybe not so much for this :lol:
Might be useful to allow a full ST emulation on a TT or Falcon though for games.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
User avatar
agranlund
Posts: 777
Joined: Sun Aug 18, 2019 10:43 pm
Location: Sweden
Contact:

Re: FPU Emulator

Post by agranlund »

stephen_usher wrote: Sun Jul 10, 2022 9:47 pm
agranlund wrote: Sun Jul 10, 2022 9:23 pm Completely nuts:
- Take total control of the computer by locking everything else, including the OS, inside a fake and virtual supervisor mode..
That might be interesting for some kind of malicious software but maybe not so much for this :lol:
Might be useful to allow a full ST emulation on a TT or Falcon though for games.
Wow, yes that's a really neat idea!
But aren't most games already patched to work on TT and Falcon by now?
User avatar
stephen_usher
Posts: 5583
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: FPU Emulator

Post by stephen_usher »

Many mostly work but PP's fixes are variable.

It would be far better if the game ran under a proper VM with TOS appropriate for the game. Catching access to hardware and then simulating it would then also allow floppy image emulation etc. You could probably fix stack frames on the fly too.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
User avatar
agranlund
Posts: 777
Joined: Sun Aug 18, 2019 10:43 pm
Location: Sweden
Contact:

Re: FPU Emulator

Post by agranlund »

stephen_usher wrote: Sun Jul 10, 2022 10:17 pm Many mostly work but PP's fixes are variable.

It would be far better if the game ran under a proper VM with TOS appropriate for the game. Catching access to hardware and then simulating it would then also allow floppy image emulation etc. You could probably fix stack frames on the fly too.
Yeah all of that should be completely doable on a 68030 with MMU.
The 68030 exception model is especially good for emulating hardware access in software.
Much more so than the later models.

It's a super interesting idea and I'm surprised no-one already did that many years ago.
User avatar
stephen_usher
Posts: 5583
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: FPU Emulator

Post by stephen_usher »

Atari probably didn’t do it on the Falcon as they were dying and didn’t have the resources, and the TT wasn’t aimed at that market.

Otherwise, there are not enough Falcons and TTs out there for people with the talent to bother.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.
mikro
Posts: 474
Joined: Mon Aug 28, 2017 11:22 pm
Location: Kosice, Slovakia
Contact:

Re: FPU Emulator

Post by mikro »

stephen_usher wrote: Sun Jul 10, 2022 9:47 pm
agranlund wrote: Sun Jul 10, 2022 9:23 pm Completely nuts:
- Take total control of the computer by locking everything else, including the OS, inside a fake and virtual supervisor mode..
That might be interesting for some kind of malicious software but maybe not so much for this :lol:
Might be useful to allow a full ST emulation on a TT or Falcon though for games.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ THIS!

To make it a bit more specific, there are two huge areas of interest to explore:

- cycle non-exact (Win)UAE (i.e. taking m68k instructions as they are) (think of modern AGA demos)
- cycle non-exact Hatari (with, say, cache disabled and perhaps some stack frame fixes) (think of dirty games overwriting memory, using disk images etc)

I'm following this project with great interest but MacOS is totally alien to me. Amiga/Atari OS on the other hand... :)
mikro
Posts: 474
Joined: Mon Aug 28, 2017 11:22 pm
Location: Kosice, Slovakia
Contact:

Re: FPU Emulator

Post by mikro »

Steve wrote: Sun Jul 10, 2022 11:29 am Very awesome! Extremely useful for MiNT users who have machines without an FPU! Thank you!!
While this is a nice project (and it certainly has some use), this particular problem (-m68020-60 requiring FPU even if it doesn't really use it) is a bigger problem to solve and this "fix" would just replace it with another problem -- instead of people complaining that their software is showing the strange error message people would report sudden and random slowness.

Much easier to explain one error message than a flood of random bug reports.
Post Reply

Return to “SOFTWARE”