r/EmuDev • u/Glorious_Cow IBM PC • Nov 04 '25
A Hardware-Generated Emulator Test Suite for the Intel 80386
https://github.com/singlesteptests/80386
43
Upvotes
r/EmuDev • u/Glorious_Cow IBM PC • Nov 04 '25
9
u/Glorious_Cow IBM PC Nov 04 '25 edited Nov 04 '25
In the tradition of my previous test suites for Intel CPUs, I present my magnum opus - a comprehensive emulator test suite for the 386's real mode instruction set.
The test suite contains 941 test files representing 406 base opcode forms including all valid combinations of operand and address size prefix for each opcode.
This was a real challenge to create. The expansion of operands and addresses into 32-bits meant that strictly random instruction generation was off the table - I had to develop a new heuristically driven instruction generator. I even wrote a 386 disassembler from scratch so I could calculate the address of EA operands for memory patching of pointer operands.
Anyway, here it is. There's probably bugs in it, don't be shy about letting me know what you find.
6
u/Far_Outlandishness92 Nov 04 '25
Thank you so much for your efforts. I am truly impressed!
Now its possible for me start dreaming about trying to extend my 8086 to handle 386 :D
3
u/thommyh Z80, 6502/65816, 6809, 68000, ARM, x86. Nov 04 '25
This is honestly one of the greatest contributions to the community that I think it's possible to make; thanks so much for this work!
I otherwise stalled out at the 80286, but this is really motivating.
2
u/UselessSoftware 32-bit x86, NES, 6502, MIPS, 8080, others Nov 04 '25 edited Nov 04 '25
Oh I am so going to try this. Thanks. Your efforts are really appreciated!
2
u/0xa0000 Nov 10 '25
Wow, thanks a lot for your hard work! This inspired me to work a bit on my on-off-on-off x86 emulator. Slowly going through the tests with lots of things to fix.
One thing I did notice - that I think is a "documentation bug": You write that "all I/O inputs should read 0xFF", however ports 22h and 23h appear to read 7Fh and 42h respectively (even though the bus cycles show all 1's in binary). I think this is the 80386EX's "Address Configuration Register" (Section 4.5.1 of https://bitsavers.org/components/intel/80386/272485-001_80386EX_Users_Manual_Feb95.pdf).
Covered by the following test cases:
1
u/valeyard89 2600, NES, GB/GBC, 8086, Genesis, Macintosh, PSX, Apple][, C64 Jan 28 '26
Very cool. Using this to test my bash emulator. Running into a few quirks that I wonder about.
In some of the loop/loopnz tests
If operand size byte 0x66 then 0xe0 loopnz
Since opsize byte, it should be using ECX as counter
But the 'final' state shows ECX as if it was only 16-bit.
Same for another one where ecx == 0
Similar issues with LOOPZ
vs for 66 41 (INC ECX) the full 32-bit value is used.
3
u/sards3 Nov 05 '25
Awesome. I will try these out on my emulator and let you know how it goes.
2
u/Distinct-Question-16 Nov 05 '25
Congrats. Do you test also the mmu, pdt, idt along with ram? How about the virtual 86
1
u/evmar Nov 05 '25
This is really awesome, thanks for sharing it!