an 8086 PC emulator

Programming, for all ages and all languages.
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

an 8086 PC emulator

Post by miker00lz »

hi.. this is something i've been working on for the last 6 or 7 months, open-source written in C from scratch. it's a PC emulator that current supports every 8086 instruction, and nearly every 80186 instruction. there is much work left to do, but if anybody is interested you can check it out here

http://fake86.rubbermallet.org
^win32 build plus source .tar.gz for linux are available :)

screenshots are there too, so you can see exactly what it's capable of so far. also, i've written it all myself so far but if any other devs are interested in teaming up with me on it i am open to that if you've got emulation skills. one thing i'm currently interested in, in particular, is somebody with really good knowledge of an ethernet adapter interface such as NE2000 since i would like to add support for one using pcap.

i'd love comments, suggestions, flames, etc. if anybody has the time and interest to take a peek.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: an 8086 PC emulator

Post by Karlosoft »

HI! Wow good job, I tried it only with the rom bios but it seems to work well :)
I'm also developing an emulator (a 80386 emulator) for my operating system (so I will be able to analize the kernel in the kernel itself with the debugger. Good luck :)
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

Karlosoft wrote:HI! Wow good job, I tried it only with the rom bios but it seems to work well :)
I'm also developing an emulator (a 80386 emulator) for my operating system (so I will be able to analize the kernel in the kernel itself with the debugger. Good luck :)
both the source and win32 bin packages come with a custom freedos install floppy image in the image\ folder if you wanted to play with it more. how far along is your emulator?
jinglexy
Posts: 15
Joined: Sat Mar 10, 2007 1:05 am

Re: an 8086 PC emulator

Post by jinglexy »

i test the emulatorfailed.(the kernel run well in bochs 2.3.6 and qemu(0.10.2 and 0.14.1)).
command: fake86.exe -fd0 image\floppy.img -boot 0

Image
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

nope, that is what i expect would happen actually. your kernel looks 32-bit. Fake86 only emulates an 8086 which is a 16-bit CPU. the same thing would probably happen if you booted that floppy on a real 8086 or 8088 computer.

thanks for having a look though. :)

if you tried running your kernel again, but add -verbose to the command line, you'll probably see your console window littered with a flood of "Illegal opcode ##" messages.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: an 8086 PC emulator

Post by Chandra »

Great! If you could just add 80386 emulation, it would be excellent.

Good job.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: an 8086 PC emulator

Post by thepowersgang »

Well, darn, this looks better than my RME project :( Well done.

Just a question, what techniques/programs did you use to debug it?

Also, is it designed to be realmode only, or strictly 8086? I tried running FreeDOS (balder10.img) and DOS 6.22 (boot622.IMA) with it, and both froze.

[edit] If you run FreeDOS, it hard freezes, and stops responding to Ctrl-C and close (Linux 2.6.38)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

Chandra wrote:Great! If you could just add 80386 emulation, it would be excellent.

Good job.
i would love to add 386 support eventually. i didn't want to make it that complex when i started on it. it definitely would be cool to see it booting linux or win95/NT.
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

thepowersgang wrote:Well, darn, this looks better than my RME project :( Well done.

Just a question, what techniques/programs did you use to debug it?

Also, is it designed to be realmode only, or strictly 8086? I tried running FreeDOS (balder10.img) and DOS 6.22 (boot622.IMA) with it, and both froze.

[edit] If you run FreeDOS, it hard freezes, and stops responding to Ctrl-C and close (Linux 2.6.38)
what's RME?

and it is strictly 8086 plus nearly all 80186 instructions. as for DOS 6.22, i'm aware of the problem actually. MS-DOS 3.2 and newer will hang when booting. i'm pretty sure it has something to do with my int 13h emulation. still trying to hunt that bug down.

with FreeDOS, the latest version uses a kernel with 286 opcodes. you'd have to recompile it for 8086, and then it would work. there is a slightly older version of it on the floppy image that i included in the download, and it works properly. i fixed the hard freeze, and it won't happen in the next version. what was happening is that if it executed a HLT, it was changing the window title to "Fake86 [halted]" and then the IP remains on that instruction... so it was changing the window title on every single instruction which made the window quit responding.

it also works with DR-DOS (tested up to 7.03)

running FreeDOS:

Image

Image




btw, last night i started writing code to emulate the adlib. still a lot of work to do on that, but it basically is working already

http://rubbermallet.org/fake86.mp3 <--- from playing ultima 6 in the emu
Last edited by miker00lz on Thu Jun 16, 2011 11:03 am, edited 2 times in total.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: an 8086 PC emulator

Post by Karlosoft »

RME is a real mode emulator ;)
I'm writing the emulation layer of many basic devices like PIC, PC speaker and so on :)
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

Karlosoft wrote:RME is a real mode emulator ;)
I'm writing the emulation layer of many basic devices like PIC, PC speaker and so on :)
ah, yeah gotcha. maybe i can help you with some details if you need it. let me know and i might be able to help.
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: an 8086 PC emulator

Post by Karlosoft »

The same for me :) If you have question that I may know I'll be happy to answer :)
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: an 8086 PC emulator

Post by thepowersgang »

(not the hijack the thread or anything)

RME (which is my Real-Mode only emulator, designed to replace VM8086 in 64-bit OSes) is currently at the "step though and compare to bochs" debugging phase, trying to iron out those tiny behavioural bugs.

If you have a different testing image to the ones that I mentioned, it would be appreciated.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
miker00lz
Member
Member
Posts: 144
Joined: Wed Dec 08, 2010 3:16 am
Location: St. Louis, MO USA

Re: an 8086 PC emulator

Post by miker00lz »

what i used a lot was emu8086 (http://www.emu8086.com) which has a built-in assembler and the best 8086 debugging interface i've ever seen. (its a windows-only program, it'll probably work fine in wine if youre on linux) i also compared output of some of my instructions with a real 8088's output. some of the trickiest stuff was getting flag calculations correct, especially on the bitshifting instructions.

i'm very confident in my CPU core now, everything i throw at it matches up with the real thing so you can peek at my code if you want. i also wrote a little test utility in assembler that checks and verifies all addressing mode calculations. it's on another one of my computers here, let me know if you want it.




alsooooooo... i added attack and decay to my adlib code http://rubbermallet.org/fake86-adlib(attack-decay).mp3

the only big thing left to do with adlib is add the percussion stuff.... not sure quite how to go about that.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: an 8086 PC emulator

Post by thepowersgang »

If you could provide that test program, that would be lovely. I hope to have this running DOS sometime soon :)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Post Reply