Hacker News new | past | comments | ask | show | jobs | submit login
V86 – An x86-compatible CPU and hardware emulator (github.com/copy)
221 points by simonebrunozzi on Sept 26, 2016 | hide | past | favorite | 54 comments



Really cool, but perhaps the title should indicate that this is an emulator that works in the browser? Perhaps a short description at the top of the readme before the demos?


Also, minimum HD requirements to run this. Otherwise, all my Firefox windows went 'Han Solo' on me ... But I think this is an awesome project, author must have learned quite a bit getting this running!


Pardon, I am unfamiliar with what it means to go "Han Solo"? Could you elaborate?


Frozen in carbonite? Just a guess.


Yup, FF simply froze ...


Thanks! I checked out urban dictionary and got the impression that perhaps you had expressed your love to your computer and it didn't return it in kind... same thing I guess.


Firefox shot first.


Slightly off-topic, but back in the day "V86" (or "VM86") used to refer to the 80386 CPU's inbult 8086 hardware virtualization mechanism: https://en.wikipedia.org/wiki/Virtual_8086_mode


One of the things that AMD broke in x86-64, and after that, both AMD and Intel decided to develop a new virtualisation mechanism completely incompatible both with V86 and each other (VT-x, AMD-V)... I think V86 mode was definitely far less appreciated than it should've been.

On the other hand, I couldn't get a working command prompt in the Win98 demo, so it seems V86 does not emulate V86 quite right. ;-)


Or the realmode x86 emulator in Xorg server.


This is really cool, I'm amazed at how smooth it runs Windows 98 in a browser.


Interestingly the popup about copy.sh having control of the cursor was somehow overlaid above my Firefox titlebar, tabs, and addressbar. Didn't know that was possible.

GIF: http://i.imgur.com/giCT1nI.gif


It's the pointer lock API:

https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Loc...

The browser tells you when a page calls requestPointerLock(), and tells you how to exit it, similar to the fullscreen API.


Booting Windows 98 in Firefox on a smart phone is a real tangible reminder of how far things have come in my lifetime.


Circa 2009, playing 80486-era Master of Orion II on the Nokia N800 using a DOS emulator. 400MHz ARM tablet, actually playable.


through multiple abstraction layers no less!


How much work would be required to allow network access from one of these emulated machines? Could it be done over websockets (via a proxy)?

EDIT: After reading the docs, it seems that this is already implemented (via websockets, too!): https://github.com/copy/v86/blob/master/docs/networking.md


> How much work would be required ...

Can't speak to his NIC emulation (unless he borrowed it from jor1k), but otherwise it'd take roughly a flight from PDX to CHS for the NIC, plus another 2-3 hours for a dead simple virtual switch, plus a few days of watching the switch crash in various odd ways while HN, Reddit, and Slashdot beat it up.

Edit: If anyone is keen to experiment around with v86, jor1k, or a similar project and you want plug-n-play network support, I maintain the websocket proxy used by jor1k (and probably used by v86 in some demo or another). As far as I'm concerned, please no commercial use (I've made it stupid easy to host your own for that), but otherwise as long as you're not doing stupid things with it that will cause me to lose my hosting account, go nuts! To use it just start sending/reading ethernet frames to/from wss://relay.widgetry.org/.

Also if you do use it, please flick me a message (e-mail is in my profile) to let me know what you're doing with it and how you're getting on.


Bro, How much time does it need to replicate a project like V86? I have close to 6 years in C++. I work for intel/amd but not on emulation, I do HW design. I want to know if this can be completed in 4-6 months doing work on the night only..

TIA.


Just take a look at the link to the third talk I gave a few days ago about jor1k.

https://github.com/s-macke/jor1k/wiki/Technical-details

This talk give a few details about time frames and what someone has to do to emulate such a machine. If it is just about booting Linux you can do it in around 2000 lines (first commit of jor1k) if you take an easy architecture such as OpenRISC. Take a look at slide no. 10 and you might get an idea about the complexity of the other architectures. Slight 15 and 16 give you an idea why OpenRISC can be emulated much faster than any other architecture. A downside of such an non-mainstream CPU is less support. Indeed as Benjamin said, at least 50% of the time went into bugfixing and enhancing the toolchain. In the end the MIPS architecture might be optimal for a fast emulation and a well maintained toolchain.


No clue how far you'd get, but I'd think you could come up with something interesting in that time frame. It's a lot more approachable than you might think.

I'm not well acquainted with Copy, so I don't know how long the bulk of the work took him. I'd suggest pinging him or Sebastian Macke (the guy behind jor1k) if you'd like to know more.

My understanding was that Sebastian chose OpenRISC in part because of the simplicity of the instruction set. I got the impression that this made the task a bit more approachable than x86 emulation, and gave him more hope for achieving a good emulation speed. And, in fact, it's quite snappy considering what it is. However I think he had to put a fair amount of effort into gcc and glibc debugging to really get it off the ground, and I know that he used to put a bunch of time into tuning the cores for each new version of asm.js, though I'm not sure how in flux it is these days.


Also, a few of the live demos have networking enabled.


But they're not internet connected, are they? I tried `ping 8.8.8.8` from each of them without any luck.


Not to detract from Copy's work (it's really quite impressive), but if you're really hard up to have a browser running in your browser, have a look at http://www.jor1k.com


I pinged successfully from the linux 3 machine. You need to run a command first though, it says so two lines above where the shell begins


Oops, I missed those lines! All working now. Thanks.


Same Origin Policy will prevent most network access from a browser tab.

You'd need to run chrome with SOP off.


I pinged google.com from the linux3 machine after enabling networking and it worked fine.


No big deal... just running windows98 on my phone...


Awesome project. I tested it with a 32 bit version of android-x86 and managed to get a mangled booting screen.

It would be so cool if android apps could run in the browser in the future with this tech.


Crazy. This one also worked on my iPhone with some kinks on the mouse.


Sheep.exe! I missed you!


didnt take long to crash it http://i.imgur.com/X8Qc8TS.png


Amazed how fast this is on my 2011 laptop...


Not compatible with Firefox... This error in JS console:

TypeError: a.table[b] is not a function

Works in Chromium though.


    > Author
    >
    > Fabian Hemmer (http://copy.sh/, copy@copy.sh)
That's not Fabrice Bellard[1]...

[1]: http://bellard.org/

[edit]: The submission title has now been edited to no longer say this is a project by Fabrice Bellard.


nice trick to make it appear in front page


Didn't Fabrice do something very similar something like 3 to 4 years back ?


Are you thinking about JSLinux? http://bellard.org/jslinux/

It does sound similar to the underlying PC emulator (http://bellard.org/jslinux/tech.html) and Bellard does indeed list v86 in section "Similar Projects (Several other PC or Linux emulators are now available)"

The v86 project's initial release was late 2013 (https://github.com/copy/v86/commit/8180d49f24833fc6cc05a9025...) about 2 years after Bellard's (http://bellard.org/jslinux/news.html)


I'd personally prefer links to GitHub projects go to their main page rather than the Readme.md since the main page has the Readme.md displayed anyways.


> by Fabrice Bellard

huh?


The "Why" section in the Readme doesn't quite explain the need for this. Can someone shed light on how and why this is useful

Thanks


When you have to ask "Why", you usually are not part of 'target audience' for this type of thing :)

All jokes aside,this is a pretty big achievement for a given programmer to complete and denotes quite a bit of technical chops on many level (hardware, systems, OS, and web dev).


Ah ok - "if you're not the target customer, no need to explain the product to you". Great mantra to live life by! You don't happen to work in marketing, do you?


Why is everything a "product"? Why does everything have to be marketed? Why does there have to be a need for something, for it to be built and to be noteworthy?

This looks like a cool personal project, built by the author as a learning experience, with a convenient API to manipulate the machine that's being simulated. If that doesn't tell you enough about why it exists, then I don't know what to tell you besides "nothing to see here".


>customer

You see, that's where you're way off base. Not everything shown here is going to be a 'product'; people often like to learn by doing, and showing what they create.


Most of this kind of stuff is done for intellectual gratification. It's playing; the tools are just more sophisticated, and it takes more brainpower than usual.


I thought they were pretty explicit: "I decided to work on this as a fun project and learn something about the x86 architecture."

That seems to be more than enough reason to me.


It is an interesting piece of software, but what is the purpose? For someone that wants to emulate a Pentium computer there are many better ways, for having fun there are many better ways, so what is left for this particular one?


Why must everything have a purpose?


I've got a lot of side projects like this one. The programming I do at work has a solid purpose. It's relaxing to work on something that isn't strictly necessary, as long as it satisfies my curiosity.

I like reading through disassemblies of DOS games and figuring out how things work. It's fun recognizing C programming patterns in the assembly. There's something a little charming about looking up what writing to some VGA control register is supposed to do...and I haven't found anyone else who actually thought any of that sounded like fun.

Someday, I'll put together a series of blog posts about it, and maybe I'll have some code that I actually want to show off, but right now I'm just having fun.


I would probably have more side projects if I could get over feeling like every one had to have a "purpose".


Or what if the purpose is "because it was fun to make", or "it was a great learning experience".


> for having fun there are many better ways

There's no accounting for taste. Building something like this sounds a lot more fun to me than most programming projects that I hear other people talk about as "fun". What would you have chosen to do instead?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: