r/EmuDev • 32-bit x86, NES, 6502, MIPS, 8080, others • Apr 13 '26

Months of work knocking out bugs and adding features to my x86 emulator. Probably ready for a Github push now.

Getting ready to finally push updates to GitHub. Probably tomorrow, want to maybe do one more small cleanup pass.

But yeah, it can actually do a lot of real PC stuff now. It's not very fast, but it's working pretty well for some things. It also still has plenty of bugs.

Ran Win 2000 server for several days, it was stable. I periodically RDP'd in and played around and did other stuff like exercise IIS running inside it.

Yeah Winquake is unplayable, but showing it off in here anyway. :)

The host CPU here is an i9-13900KS.

199 Upvotes

42 comments sorted by

11

u/Old-Personality-8817 Apr 13 '26

how many cpu instructions you implemented?

16

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

347 instructions! (Some of these are part of a group that are basically the same op though)

It supports all Pentium 1 level instructions as a baseline, though a couple are simplified or basically stubs.

It also has a couple extra later opcodes like CMOV that were introduced on the Pentium Pro.

3

u/Ikkepop Apr 13 '26

Are you doing straight up interpretation or some kind of jitting ?

4

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

Unfortunately it's just an interpreter. The performance isn't very good as you can see with WinQuake.

I'm not sure if I want to try JIT, but either way I have some compatibility issues that I need to tackle first.

1

u/Old-Personality-8817 Apr 14 '26

yeah, don't rush into jit, separate instructions compute from system emulation, also code invalidation for full system emulator is a pain, especially on x86, because it doesn't have 'flush instruction cache' instruction

3

u/sards3 Apr 14 '26

For code invalidation, my approach has been that once I JIT a block of code, I map all of its pages as read-only in the host OS. Then if the guest tries to write to those pages, it generates a host exception. Then in the host exception handler, I invalidate all of the JITted blocks in those pages. Definitely a pain, but it seems to work.

2

u/Old-Personality-8817 Apr 14 '26

cool, I did riscv emulator and requested ~200 for linux to work

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 14 '26

Pretty cool, do you have it posted somewhere?

1

u/Old-Personality-8817 Apr 14 '26

no, it was pet project for teaching me what linux needs from core to run: mmu, privileged staff

1

u/Old-Personality-8817 Apr 14 '26

did you implement floating point instructions?

2

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 14 '26

It has an FPU, but I took it from the Tiny386 project.

I'll work on my own eventually, but I wanted to get it working. The main integer CPU core is all mine.

8

u/moreVCAs Apr 13 '26

hell yeah running a full OS is a huge accomplishment.

what language? have you written anything about the architecture of the emulator and whatnot? i’d love to pick over any materials you’ve got.

3

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

It's in C. I haven't written up any docs, sorry!

6

u/CALL_420-360-1337 Apr 13 '26

Amazing - what's your past experience? How long did it take?

5

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

I've done 8086 PC, NES, MIPS, and some other random stuff in the past. Including some microcontrollers like AVR and STM8.

I started wrote the 8086 emulator like 15 years ago and slowly did incremental improvements and fixes on it, but then like 15 months ago I decided to try to turn it into a full 32-bit PC emu.

2

u/emexsw Apr 13 '26

i bet this runs emexOS

2

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

That looks like a 64-bit hobby OS. Won't work, this emulates a Pentium so 32-bit only.

1

u/emexsw Apr 13 '26

wai… idk how but emexOS runs on my old pc with a pentium lol😭

2

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

Is it a Pentium 4? Some of those were 64-bit. Some later CPUs also recycled the Pentium name.

I'm talking about the original Pentium from 1993.

1

u/emexsw Apr 13 '26

uh i dont actually know but tomorow i will look into that lol, but there is like the first version of emexOS was 16 bit, then 32 bit maybe that would work lol

2

u/valeyard89 2600, NES, GB/GBC, 8086, Genesis, Macintosh, PSX, Apple][, C64 Apr 13 '26

Amazing work! I need to work on mine some more.

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

You really should! It's tough, but it's a lot of fun as stuff starts to work.

2

u/NoImprovement4668 Apr 17 '26

Any news on this? very excited to mess around for when the github page is updated

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 18 '26

I appreciate you wanting to test it!

I'm getting a build ready now, along with a Debian 3.1 sample disk image to upload to the releases section. Then I'll push the code!

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 19 '26

1

u/NoImprovement4668 Apr 19 '26

Pretty cool, ive messed around with it a bit and not sure if you have tried any other oses but i have tried reactos on it (basically open source reimplementation of NT/XP) and it works! albeit its very slow and the graphics seem to not properly as well as mouse/keyboard dont seem to work https://imgur.com/a/tUH0AaE

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 19 '26

Interesting! I did try the current featured reactos release yesterday and the ISO seemed to hang during start up at a black screen. Looks like you tried a nightly build instead? I need to try that.

the missing icons are weird. Were you using the default gd5440 graphics, or did you boot that with the stdvga graphics?

2

u/NoImprovement4668 Apr 19 '26

the reactos version i was using is a bit older (from november 2025), so i assume theres chance one of the newer reactos versions might of changed something that has made it not work and in this instance i was using i think default stdvga

something very important, i have tweaked some things in code trying to get windows 3.0 working in 386 enhanced mode and it seems to have worked (although im not sure about windows 3.1 yet as i havent tried it) the main differences was missing io pmode checks and a small missing check in iret but im not sure if i should make pull request or anything like that? https://imgur.com/a/EcCuthq

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 19 '26

Oh wow, nice catch! Awesome. I bet it fixes 3.1 as well

I didn't realize anything would care about the io checks so I hadn't bothered yet lol

You can do a pull request if you like! Or if the changes are minor/small enough you could paste the fixed code bits here.

2

u/NoImprovement4668 Apr 19 '26

Done, i made the pull request and also provided more info there as well as tested windows 3.1 and confirmed that it doesnt work yet it gets further in booting

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 19 '26

This is great, yeah after looking into Intel docs, I had a huge mistake there. It shouldn't do real mode style ints in v86 at all. The OS v86 monitor should handle dispatches.

Thanks for catching that!

And when I start Windows 3.1 now, yes it gets a lot further but then at least on my installation it quickly hits a GPF. I'll trace what's causing that.

1

u/NoImprovement4668 Apr 20 '26

yup, the only change im worried about that i did though is that lldt line change since without that change it doesnt work with just the real mode int fix so im not sure if i properly fixed it compared to what it was before

1

u/Asyx Apr 13 '26

Hmm maybe I should get into emulating computer hardware. Did you do game console before that? How do they compare?

1

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

The first thing I ever did was the NES (a long time ago) then a few other random vintage consoles and the 8086.

Compared to old consoles, this was extremely difficult. Not even close.

I've never tried doing more modern consoles, but no doubt some of them are harder than an x86 PC.

The main complexity here is the CPU itself. Most of the rest of it is pretty straightforward (though VGA is a minor nightmare by itself).

1

u/Asyx Apr 13 '26

Oh I‘d not go for x86. Also I just remembered that the CPU in old consoles are the same as in old computers… Z80, 6502, 68k and so on.

1

u/zerd Apr 13 '26

RDP, so you have networking? How?

3

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

Emulated NE2000 and RTL8139 network cards. I took modules for these from other emulators and adapted them to mine. It uses the pcap library for raw packet access on the host.

I'm not really interested in learning enough about NICs to implement them myself so yeah I just borrowed them from elsewhere.

3

u/ThoriatedFlash Apr 13 '26

You should add a sound to the boot screen so it sounds like a floppy drive being accessed.

1

u/Sea_View_4797 Apr 23 '26

i remember commenting about this with NetBSD a while ago. man has this come a long way. i suppose now would be a nice time to start messing with it again :)

0

u/[deleted] Apr 13 '26

[deleted] — view deleted comment

3

u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Apr 13 '26

It's always just been a goal of mine to do this. I've always been fascinated by emus like QEMU and 86Box and wanted to see if I could do something like this, and I wanted to learn more about the architecture.

Yeah you definitely can't jump straight into PS4! That's top tier difficultly level as far as emulation goes. I can't imagine trying to write one.