an 8086 PC emulator

Programming, for all ages and all languages.
User avatar
Artlav
Member
Member
Posts: 178
Joined: Fri Aug 21, 2009 5:54 am
Location: Moscow, Russia
Contact:

Re: an 8086 PC emulator

Post by Artlav »

Nice work.

If you're interested, here is my collection of testsuites for EPC's 80186:
http://orbides.1gb.ru/80186_tests.zip
res_*.bin contains the results expected at the offset 0x0 when you run *.bin test placed as a BIOS.

Although, if you have win 3.0 booting these are a little late.

About the timing - do you want to get precise real-time experience or something?
You won't get away from CPU overuse without many tricks. There is nothing better then scheduling to free the CPU (like sleep(1);), but it's hard to predict the duration.
Best results will be with rdtsc and active waiting, but you're still subjected to task switching.
Why bother?
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 »

Artlav wrote:Nice work.

If you're interested, here is my collection of testsuites for EPC's 80186:
http://orbides.1gb.ru/80186_tests.zip
res_*.bin contains the results expected at the offset 0x0 when you run *.bin test placed as a BIOS.

Although, if you have win 3.0 booting these are a little late.

About the timing - do you want to get precise real-time experience or something?
You won't get away from CPU overuse without many tricks. There is nothing better then scheduling to free the CPU (like sleep(1);), but it's hard to predict the duration.
Best results will be with rdtsc and active waiting, but you're still subjected to task switching.
Why bother?
yeah the timing is for generating the real-time clock interrupt, as well as generating audio samples for output at the proper intervals. also, that link you gave is a 404. even though i've got win 3.0 booting, i'd still like to run it and see what happens. thanks.
User avatar
Artlav
Member
Member
Posts: 178
Joined: Fri Aug 21, 2009 5:54 am
Location: Moscow, Russia
Contact:

Re: an 8086 PC emulator

Post by Artlav »

Try again, i don't usually delete hosted files, so i didn't bother to check. :(

About timer/RTC interrupt - isn't it related only to the CPU?
There should be a clock counter in CPU emulation, based on instructions executed, and the interrupt is called based on that.
You can then pad the CPU to average it at a given clock rate per real second, and you'll get a real-time system.
About the sound - no ideas, never implemented it.
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 »

Artlav wrote:Try again, i don't usually delete hosted files, so i didn't bother to check. :(

About timer/RTC interrupt - isn't it related only to the CPU?
There should be a clock counter in CPU emulation, based on instructions executed, and the interrupt is called based on that.
You can then pad the CPU to average it at a given clock rate per real second, and you'll get a real-time system.
About the sound - no ideas, never implemented it.
no the timer interrupt is based on a 1,193,180 Hz master clock regardless of CPU speed. it's divided by the value that you program into PIT channel 0. a PC's BIOS initially sets the dividier to 65536, which is 18.2 Hz. games often change it to go faster.

for the audio, i'm using it to generate correct frequencies for the PC speaker and adlib channels based on sample rate divided by output freq per channel. it's working well as i have it, i was just hoping for a less CPU intensive method than constant polling.

also, i got the tests zip. thanks!
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 »

big update..

so, i've uploaded a current snapshot which should be considered unstable, but it's got Adlib emulation (not the greatest yet), plus Disney Sound Source, PC speaker, and networking support. if anybody wants to try it and let me know how it works for them, that would be awesome. :)

some programs dont like work with the networking yet for some reason, for example arachne. i'm trying to find out why. some things run fine with it.

my announcement of it with more detailed info:
http://fake86.rubbermallet.org/?article ... le-release

download the win32 compiled binaries package:
http://fake86.rubbermallet.org/?downloa ... -win32-zip

or, if you're on linux, the source tarball. run build.sh in it:
http://fake86.rubbermallet.org/?downloa ... -24-tar-gz

you must have the libsdl 1.2 development library installed to compile. in debian/ubuntu - apt-get install libsdl1.2-dev

and here is a 20 MB sample hard drive image with FreeDOS pre-installed, along with Wolfenstein 3D (which is really nice now with complete sound) and some other games:
http://fake86.rubbermallet.org/?downloa ... 6_drive-7z

^extract that to the folder you have the fake86 binary in and run fake86 -hd0 drive.raw

have fun! the code is quick enough to play Wolf3D smoothly on a 1 GHz pentium 3. :twisted:
User avatar
ASMMan
Posts: 14
Joined: Fri Jan 18, 2013 10:35 pm

Re: an 8086 PC emulator

Post by ASMMan »

Thanks for share it. Great job,man. I really like it. I'm performing some testing now. I been to able to run MS-DOS. I explored it,really. I played the game that you included thanks. But I'm not able to run a small kernel write with as86(by the way, what assembler are you using?) assembler. It run fine in my computer. I have maked the .iso file by using dd and mkisofs UNIX's programs combination. And so I write it to a CD-ROM. Ran fine as I've mentioned. By in the fake86 it disn't work. By default it doesn't print any error message(right?) and so I was looking for some way to get some state of current running process. I added the -verbose flag and I can see

Code: Select all

Set video mode 30h
Set video mode 20h
Set video mode 07h
Set video mode 03h
Illegal opcode: 65 @ 0000:0108
Illegal opcode: 65 @ F000:E03B
Illegal opcode: 65 @ F000:E03B
Illegal opcode: 65 @ F000:E03B
Illegal opcode: 65 @ F000:E03B
Set video mode 00h
why I'm getting this errors messages? what does this that mean?

Code: Select all

entry start
start:
      mov ax,#0xb800
      mov es,ax
      seg es
      mov [0],#0x41
      seg es
      mov [1],#0x1f
loop1: jmp loop1
The OS code is very very simple. Just print the 'a' letter in black color with blue background. I have get it from a page in the internet. A tutorial that I have read. This is as86 syntax; I had never touched it before.

I have make the file with:

Code: Select all

as86 boot.s -o boot.o
ld86 -d boot.o -o boot
boot.s is the above assembly code.

Another thing that I noticed,sometimes the emulator doesn't run correctly and exit because a segmentation fault error has been happened. As it just happen sometimes,I think that we have an UB in your C program?

and +1 thanks for provide a easy-to-install program. Unlike almost all linux programs where usually you enter in a stupid iteration of miss-packages. Not all cases a programs such as apt-get and zypper are enough.

Also, I'm a C programmer. I will read the source code. If a can provide some help to emulator, I will do.

(sorry for my bad english; not my native language speaker)
User avatar
ASMMan
Posts: 14
Joined: Fri Jan 18, 2013 10:35 pm

Re: an 8086 PC emulator

Post by ASMMan »

I solved the problem of 'Ilegal opcodes'. It's fine now. The problem was because I had not put the PC signature in the binary file. 0x55 and 0xAA at byte 511 and 512 respectively. I have another question,not sure if an error in the program. But sometimes the emulator open the emulator itself in full screen mode,even if -fullscreen isn't passed in the command-line-options. And when it happens,I have no idea how to get out from there. My GUI environment is KDE,CTRL+ESC open the system process management,but it doesn't work. But after release the mouse by ctrl+alt keys combination and then I need to force the computer to reboot.

Also,thanks so much again for share it this program. I'm looking for sometime to contribute by some way.
Post Reply