English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 29 November 2015, 11:14   #1
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
Best 68040 emulator

Hi,

I've got a long shot project planned. My requirements:

- I want to run some 68040 code on a windows machine
- I don't care for any custom stuff (blitter, copper...), it's not amiga code
- The emulation solution must be open-source
- I must be able to install some "hooks" on traps/illegal/PC=such or such address to call "native" windows functions

Any serious candidate?

thanks
jotd is online now  
Old 29 November 2015, 12:56   #2
Locutus
Registered User
 
Join Date: Jul 2014
Location: Finland
Posts: 1,175
there is QEMU 68k support nowadays, it wont do calling to windows stuff out of the box but its opensource and the closest to your feature request box you are going to find.

Check:

https://github.com/vivier/qemu-m68k

and https://wiki.debian.org/M68k/sbuildQEMU

I cant tell you exactly how accurate it is yet, but ive not run into any problems with gcc compiled code (including recompiling gcc itself).

Also, its quite a bit faster then WinUAE/Aranym :-)
Locutus is offline  
Old 29 November 2015, 13:52   #3
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
Does "68040" mean = "68020 + added 68040 instructions" or full 68040 including MMU and FPU and all?

UAE (or QEMU) probably is far too complex if simple 68020 (+some extra instructions) is all you need.
Toni Wilen is offline  
Old 29 November 2015, 14:52   #4
Locutus
Registered User
 
Join Date: Jul 2014
Location: Finland
Posts: 1,175
QEMU has a Usermode target for that though, which greatly cuts down on complexity. I'm not sure what other 68k emulator you would use otherwise.
Locutus is offline  
Old 29 November 2015, 16:08   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
Qemu is the one! I ll probably need fpu. Thanks guys!

Edit: QEMU usermode sounds interesting but it needs linux...

Well if address spaces are compatible, I'd like to try playing with WinUAE:

- boot without startup sequence with a lot of memory i.e. the widest addressing space possible
- load the chunk in memory with allocabs() if possible or a memcpy (with a resident program like whdload in case the memory zone destroys the OS)
- zero VBR, SR... and start the proggy

The part I'm puzzled about is how to plug some "native" events: ex: I reach a given PC or zone: winuae calls some of my code/scripts (like python, C??). That would allow me to connect my program to the outside world (windows)
I'm sure it is possible with WinUAE right?

Last edited by jotd; 30 November 2015 at 23:15.
jotd is online now  
Old 23 December 2015, 10:21   #6
meynaf
son of 68k
 
meynaf's Avatar
 
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
Quote:
Originally Posted by jotd View Post
Edit: QEMU usermode sounds interesting but it needs linux...
I'd like to play with some cpu emulation as well, like trying to add new instructions in the cpu, and call some kind of "native" features.
It seems QEMU won't do it with a windows compiler...


Quote:
Originally Posted by jotd View Post
Well if address spaces are compatible, I'd like to try playing with WinUAE:

- boot without startup sequence with a lot of memory i.e. the widest addressing space possible
Just configure the mem in winuae's settings and you're done.
You can get 1.5GB of Z3 fastmem

However you won't have a direct access to the host's address space.


Quote:
Originally Posted by jotd View Post
- load the chunk in memory with allocabs() if possible or a memcpy (with a resident program like whdload in case the memory zone destroys the OS)
- zero VBR, SR... and start the proggy
If you don't need any OS on the Amiga side, perhaps you can just replace the Amiga ROM by other code.


Quote:
Originally Posted by jotd View Post
The part I'm puzzled about is how to plug some "native" events: ex: I reach a given PC or zone: winuae calls some of my code/scripts (like python, C??). That would allow me to connect my program to the outside world (windows)
I'm sure it is possible with WinUAE right?
From what i've read WinUae has the ability to call native x86 code.
But i don't know how to do that.

Hacking winuae is possible as well, because sources are available... even though it's far from being easy.
meynaf is online now  
Old 24 December 2015, 23:22   #7
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
Where relevant:

I optimize for the worst case (68000) and use 68020+ instructions only when needed for performance on 68020+, but I can see that fallback compatibility is more important to me and I'm a bit extreme in the way that I only really care about 68000 and 68060.

But it's good advice to avoid if you can instructions removed in the 68060 (which IMO is even better designed than the very nice 68040!), and also to not rely on Copyback Cache features. While both these helped with performance, they're also the reason for software requiring patches. If a CPU emulator or compiler has a 68060 mode (is there one??), do use it and it might warn you so you can avoid it.
Photon is offline  
Old 19 November 2019, 10:07   #8
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
reviving an old thread.

I've finally use Basilisk (using winuae core) but now we're stuck because it's GPL so we cannot use it in our commercial product (yes, I'm working on a 680x0 related thing at my job )

I've checked musashi which is completely non GPL but also completely 68020 max

Any other ideas?
jotd is online now  
Old 19 November 2019, 12:00   #9
Hewitson
Registered User
 
Hewitson's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Age: 41
Posts: 3,771
Quote:
Originally Posted by jotd View Post
I've checked musashi which is completely non GPL but also completely 68020 max
Quote:
Originally Posted by https://github.com/kstenerud/Musashi
Musashi is a Motorola 68000, 68010, 68EC020, 68020 and 68040 emulator written in C. This emulator was written with two goals in mind: portability and speed.
But I see what you mean, 68040 can not be selected.
Hewitson is offline  
Old 19 November 2019, 12:00   #10
Cyprian
Registered User
 
Join Date: Jul 2014
Location: Warsaw/Poland
Posts: 171
what about ARAnyM https://aranym.github.io/
It offers emulation - CPU: 68040 with MMU and FPU 68882

Last edited by Cyprian; 19 November 2019 at 12:00. Reason: ARAnyM
Cyprian is offline  
Old 19 November 2019, 13:33   #11
britelite
Registered User
 
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 818
Quote:
Originally Posted by Cyprian View Post
what about ARAnyM https://aranym.github.io/
It offers emulation - CPU: 68040 with MMU and FPU 68882
It's also GPL, so that's a no-go
britelite is offline  
Old 19 November 2019, 13:45   #12
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
I don't need MMU. 'Just' the 040 instructions and FPU. Adding 040 support to Musashi would be the best option.

And if there's a non-GPL 680x0-binary software which is able to emulate 040 instructions by software on a 68020 that could work too. Speed isn't too much of an issue, we can use fast machines to emulate that, we're a company
jotd is online now  
Old 19 November 2019, 21:07   #13
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,502
If not including MMU, 68040 in instruction level has very few new instructions: MOVE16 and cache instructions (CINVx, CPUSHx). CACR bits have changed. Cache instruction can be ignored unless you need to run some kind of OS or program that uses CACR bits to detect CPU model.

FPU is also almost same except D and S (FDADD, FSADD etc) instruction variants are new and not supported by 68881/68882. (But 6888x emulation may still support them)

Both should be relatively easy to implement in existing 68020/030 + 6888x emulation.
Toni Wilen is offline  
Old 19 November 2019, 21:49   #14
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
Thanks Toni. I don't need cache instructions either or CACR. Actually I'm emulating an application. It's running in supervisor mode (I know it sucks!) but not as an operating system (it handles some traps, peeks into the VBR to get some OS vector (dirty, I have stubbed that), so it seems that I can start from musashi 020. At least 95% of the instructions are correct. And the ones that aren't, I can compare in/out with UAE core.

Actually it's the fact that I have plugged one of our proprietary OS (simulated) that renders the whole GPL thing impossible since I'm not allowed to disclose the source for the simulated proprietary OS. Joys of open source.

Now I have to provide an estimate and I'll have to code that IN MY OFFICE TIME oh dear… At least we won't be needing to provide the source of the thing. I'm regaining hope, and the project managers will be pleased because they don't like GPL too much.
jotd is online now  
Old 20 November 2019, 10:35   #15
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Can't you package the emulator and the proprietary OS separately to get around the GPL thing? I mean, if you only need minor mods on the emulator (which hardly would be worth protecting as your IP if they're just a few 68040 add-ons), then implement those and contribute them back to the community...
hooverphonique is offline  
Old 20 November 2019, 18:59   #16
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
> if you only need minor mods on the emulator

that's not minor mods. that's plugging the emulator on our custom OS API & removing everything but the CPU emulation We had a talk with legal dep and we can't. And I can't disagree with that.

Of course I didn't mind provide the source of the modified thing, but that's not enough.
jotd is online now  
Old 07 March 2020, 10:32   #17
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,160
problem solved: switched from UAE/Basilisk core to musashi.

After *ahem* a few changes, the code is running properly. I've "forked" musashi on my repo with my changes, hoping that they'll make into the official repo.

https://github.com/jotd666/musashi040

I found issues with CHK2/CMP2 instructions & TRAP16/32 stackframes manually/implemented some missing FPU instructions & modes.

Then, since it wasn't running properly, I recorded a complex computation done with Basilisk core and musashi core on the same program and compared the FPU regs & PC, fixed the remaining FPU instructions errors, until it matched 100%

Who has time for this? Well, me, at work, with my bosses telling me to do it
jotd is online now  
Old 14 August 2022, 19:00   #18
dirkwhoffmann
Dirk Hoffmann
 
dirkwhoffmann's Avatar
 
Join Date: Jun 2019
Location: Karlsruhe
Posts: 33
Hi Jotd. I'm excited to read that you've build a test program which runs Musashi against Basilisk. I am doing exactly the same thing with Moira (which is the CPU powering vAmiga). What I did is to implement a "tesrunner" that iterates over all opcodes and executes them with random register and memory values both with Moira and Musashi. In runs in an endless loop until a mismatch is found. Is your testing code (Basilisk vs. Musashi) available in some public repo? If so, I could probably add Basilisk as another "reference core" to the Moira test runner without having to dig too deep into the Basilisk / UAE sources. Running all three cores against each other might reveal some more bugs in Musashi (and my own CPU).
dirkwhoffmann is offline  
Old 15 August 2022, 06:59   #19
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
I also added some fixes to the fpu: https://github.com/bebbo/Musashi
And there is no pull request, since previous pull requests did not work out^^

EDIT: there maybe even more fixes in the musashi of my amitools fork: https://github.com/bebbo/amitools. With these changes the gcc execute testsuite runs successfully with vamos.

Last edited by bebbo; 15 August 2022 at 07:32.
bebbo is offline  
Old 15 August 2022, 08:33   #20
dirkwhoffmann
Dirk Hoffmann
 
dirkwhoffmann's Avatar
 
Join Date: Jun 2019
Location: Karlsruhe
Posts: 33
Beppo, thanks for sharing the updated Musashi core. I'll merge those changes into my local version of Musashi. My own CPU is not able to do any FPU stuff at the moment, but I plan to add those capabilities in the future. Having a reliable reference implementation is invaluable for this task.
dirkwhoffmann is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
T-zer0 and 68040 PopoCop support.Games 0 06 July 2013 15:08
68040 vs 68060 tesla support.Hardware 10 20 April 2013 19:13
68040/60 speed Seiya support.WinUAE 2 19 January 2010 10:28
Replace 68040 cybernoid support.Hardware 5 17 May 2007 21:33
Frederic's Emulator inside and Emulator thread Fred the Fop Retrogaming General Discussion 22 09 March 2006 07:31

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:57.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.09375 seconds with 13 queries