This may as well be magic as far as I'm concerned. When I first saw http://bellard.org/jslinux/ I just about shat myself. This is definitely another level of awesome. Well done.
This really is extremely well done [and I'd like to see the unminified source]. The next feature I'd want to see is networking support. I love the idea to be able to run my entire dev setup in an emulated browser session [e.g. ruby, rails, redis]. That would be a game changer on how I'd develop.
I just ran Bellard's JSLinux (#) on my retina iPad with iOS 7. It works! Booting took 15 sec. Claims 20 bogoMips. And I can type the commands in it and execute them:
First I tap to the edit box on the right, the keyboard rolls in, then I tap in the "console." The commands work. I just don't know how I'd type ctrl-Keys without the physical keyboard.
Copy.sh ends with unimplemented GP handler however for anything I've tried.
#) JSLinux: the PC emulator is written in Javascript with the emulated hardware: 32 bit x86 compatible CPU,
8259 Programmble Interrupt Controller,
8254 Programmble Interrupt Timer,
16450 UART,
Real Time Clock,
IDE interface and hard disk. http://bellard.org/jslinux/tech.html
Wait how does this differ from JSLinux? Aren't they doing the same thing?
Also, this isn't just an x86 emulator, right? If it can boot linux, it's emulating the entire PC platform, not just x86. Very impressive of course. But I am interested in a comparison vs jslinux (also not open source).
Interesting bug: I can't seem to type '-', '=', '+', or '_' into the Linux image. Missing '-' in particular makes it hard to run commands with options.
Elaborate workaround:
/root% eval eq$(dmesg | grep 'e820 update' | sed 's/.*) \(.\).*/\1\1/')
/root% echo $eq
=
/root% eval dash$eq$(uname bad 2>&1 | grep Usage: | sed 's/.*\[\(.\).*/\1/')
/root% echo $dash
-
/root% uname ${dash}a
Linux (none) 2.6.34.14 #44 Tue Oct 15 20:50:15 CEST 2013 i586 GNU/Linux
The first command grabs an '=' from dmesg and sets "eq" to it (without typing '='), and then the second command grabs a '-' from the usage message of uname and sets "dash" to that (without typing '-'). The last shows how to use ${dash} in a command.
This is the most soul-crushing category of bug, the kind which keeps me up all night, drinking.
Build a skyscraper, and lock the keys inside for the ribbon cutting. Sorry pal you lost your funding
Land on Mars, see an alien, but your camera is out of batteries and everybody back on Earth thinks you're a quack.
Successfully perform open-heart surgery on a desert island, but muck up the stitches and cause a scar. Your patient will hold it against you the rest of his life (which you saved).
I found that bug too. First thing I did was think, "a system restore is a page refresh away and I've always wanted to test the effects of this", then I attempted to type "rm -r /*".
Pretty awesome, I for one don't think the constant stream of "x, rewritten completely in javascript" is tiring (this is not meant to be sarcastic).
[EDIT] - This post doesn't seem to say enough when I look back at it. Wanted to add this:
Seeing posts like this really excites me (and inspires me) about the future of web programming, and programming in general. Anyone that's excited about programming has to get excited about abstraction, and it doesn't get much more abstract that cross-coded/implemented virtualized systems like this. Even if you hate javascript.
Every step people take in blurring lines between systems like this should be exciting, given the large amount of abstraction that had to go into creating something like this.
Then it usually dies for low memory - and I can't enter anything at all without keyboard (which doesn't pop up) - but still. The fact that I can boot up a x86 emulator in javascript in browser on ARM mobile phone is crazy.
My second computer was an IBM XT 8086. That was the first time I played and fell in love with Rogue. Every time I grab a copy of Rogue nowadays for nostalgia's sake I'm left disappointed because I can never find the version of Rogue that I played as a kid.
My friend, your emulator has that version of Rogue. The kid inside me thanks you greatly.
You might want to consider re-ordering the font list in the console though. Consolas isn't perfectly fixed-width apparently, and it made Rogue rather puzzling to play.
I know this sounds like crazy pants, but I would actually use this in the real world if it were a NodeJS module.
Not for anything compute-intensive or serious, but for creating very secure very isolated VMs to run web apps or other services in an insecure environment. It could also be a great way to take a LAMP stack app and rapidly deploy it in certain cases.
Again not for high performance, but for... I can think of a few things personally and I'm sure others can too.
(Though honestly performance wouldn't be that bad...)
Then add the ability to go back and forth between client and server, and virtual networking, and you might have a commercial "virtual DOS LAN with nodes in a browser as a service" startup. What for? Supporting legacy DOS crap: point of sale systems, etc. "Run your legacy DOS stuff in your browser with persistence in the cloud." You'd be surprised how much legacy DOS crap is out there.
The project is made with both browser and nodejs support in mind. There are still some issues to resolve, but I will definitely release a node version this year.
There are two sensible approaches: interpretation or dynamic translation.
If you want to write one as a learning experience for how the platform you're emulating works and how an emulator could work in principle, you probably want to write an interpreter: find out how the platform boots, build something to start reading and interpreting instructions, start adding emulated hardware devices, and you'll get an increasingly functional interpreter.
For a start, you could ignore emulation of devices, and just write a CPU core that interprets instructions.
If you want to learn how modern (but still non-hardware-assisted) emulation works, read about how qemu's dynamic code translator and other JIT compilers work, and build a CPU emulator based on that.
I'm not the OP but check out the book: "The Elements of Computing Systems: Building a Modern Computer from First Principles" It's quite comprehensive, not exactly about writing an emulator, but it should give you what you need.
g3: Probably you have seen my emulator.
http://s-macke.github.io/jor1k/
It does more or less the same, but emulates a different CPU.
Your emulator is impressive and especially fast. I think it took a long time for you to optimize it.
I tried to start TinyCore, but it stops after decompressing the kernel. So still some work to do ;)
I saw the source and I have some tips for you:
Avoid the UInt32 Arrays and the >>> operator.
They could be transformed by the JIT compiler into doubles and slow everything down. This does not happen with the Int32 Arrays and the >> operator.
There is a plug-in called JIT-Inspector which give you this information. Unfortunately it does no longer work in Firefox 24. Firefox 22 was the last working version.
Additionally worker threads gave me an incredible speed boost in Firefox. The whole GUI stuff is then separated. Especially the costly canvas update.
[+] [-] staunch|12 years ago|reply
[+] [-] ghayes|12 years ago|reply
[+] [-] acqq|12 years ago|reply
First I tap to the edit box on the right, the keyboard rolls in, then I tap in the "console." The commands work. I just don't know how I'd type ctrl-Keys without the physical keyboard.
Copy.sh ends with unimplemented GP handler however for anything I've tried.
#) JSLinux: the PC emulator is written in Javascript with the emulated hardware: 32 bit x86 compatible CPU, 8259 Programmble Interrupt Controller, 8254 Programmble Interrupt Timer, 16450 UART, Real Time Clock, IDE interface and hard disk. http://bellard.org/jslinux/tech.html
[+] [-] chubot|12 years ago|reply
Also, this isn't just an x86 emulator, right? If it can boot linux, it's emulating the entire PC platform, not just x86. Very impressive of course. But I am interested in a comparison vs jslinux (also not open source).
[+] [-] _ak|12 years ago|reply
[+] [-] bumbledraven|12 years ago|reply
[+] [-] JoshTriplett|12 years ago|reply
Interesting bug: I can't seem to type '-', '=', '+', or '_' into the Linux image. Missing '-' in particular makes it hard to run commands with options.
Elaborate workaround:
The first command grabs an '=' from dmesg and sets "eq" to it (without typing '='), and then the second command grabs a '-' from the usage message of uname and sets "dash" to that (without typing '-'). The last shows how to use ${dash} in a command.[+] [-] Sheepshow|12 years ago|reply
Build a skyscraper, and lock the keys inside for the ribbon cutting. Sorry pal you lost your funding
Land on Mars, see an alien, but your camera is out of batteries and everybody back on Earth thinks you're a quack.
Successfully perform open-heart surgery on a desert island, but muck up the stitches and cause a scar. Your patient will hold it against you the rest of his life (which you saved).
[+] [-] g3|12 years ago|reply
[+] [-] laumars|12 years ago|reply
eg your $eq code can be written like this:
[+] [-] femto|12 years ago|reply
[+] [-] darkstalker|12 years ago|reply
[+] [-] Aardwolf|12 years ago|reply
[+] [-] hardwaresofton|12 years ago|reply
[EDIT] - This post doesn't seem to say enough when I look back at it. Wanted to add this:
Seeing posts like this really excites me (and inspires me) about the future of web programming, and programming in general. Anyone that's excited about programming has to get excited about abstraction, and it doesn't get much more abstract that cross-coded/implemented virtualized systems like this. Even if you hate javascript.
Every step people take in blurring lines between systems like this should be exciting, given the large amount of abstraction that had to go into creating something like this.
[+] [-] mambodog|12 years ago|reply
At the moment I've only uploaded a demo of the Mac Plus emulator (classic 68k mac) but I'll upload IBM PC and Atari ST demos soon also.
[+] [-] mambodog|12 years ago|reply
IBM PC with Wolfenstein 3d, Civilization, Monkey Island: http://jamesfriend.com.au/pce-js/ibmpc-games/
IBM PC with Windows 3.0: http://jamesfriend.com.au/pce-js/ibmpc-win/
Mac Plus with applications and games: http://jamesfriend.com.au/pce-js/pce-js-apps/
[+] [-] nwh|12 years ago|reply
[+] [-] cokernel_hacker|12 years ago|reply
[+] [-] agilebyte|12 years ago|reply
[+] [-] aray|12 years ago|reply
[+] [-] sramsay|12 years ago|reply
Still, this wins the Nobel Prize for awesome.
[+] [-] TeMPOraL|12 years ago|reply
(@Eliezer, how's the work going? ;))
[+] [-] general_failure|12 years ago|reply
[+] [-] runn1ng|12 years ago|reply
On Android.
Then it usually dies for low memory - and I can't enter anything at all without keyboard (which doesn't pop up) - but still. The fact that I can boot up a x86 emulator in javascript in browser on ARM mobile phone is crazy.
[+] [-] pcwalton|12 years ago|reply
[+] [-] mVChr|12 years ago|reply
My friend, your emulator has that version of Rogue. The kid inside me thanks you greatly.
[+] [-] Aardwolf|12 years ago|reply
In any case, super awesome! Great work :)
EDIT: Whoa, the dos one has games on it! Can you make Wolf3D work? :)
[+] [-] Pitarou|12 years ago|reply
[+] [-] McGlockenshire|12 years ago|reply
You might want to consider re-ordering the font list in the console though. Consolas isn't perfectly fixed-width apparently, and it made Rogue rather puzzling to play.
[+] [-] sillysaurus2|12 years ago|reply
I assumed something named consolas would be a font suitable for consoles.
Which font do you like to use?
[+] [-] jordwalke|12 years ago|reply
1. How can we help? How can I support you? 2. Please open source this.
[+] [-] tectonic|12 years ago|reply
[+] [-] elwell|12 years ago|reply
[+] [-] api|12 years ago|reply
Not for anything compute-intensive or serious, but for creating very secure very isolated VMs to run web apps or other services in an insecure environment. It could also be a great way to take a LAMP stack app and rapidly deploy it in certain cases.
Again not for high performance, but for... I can think of a few things personally and I'm sure others can too.
(Though honestly performance wouldn't be that bad...)
Then add the ability to go back and forth between client and server, and virtual networking, and you might have a commercial "virtual DOS LAN with nodes in a browser as a service" startup. What for? Supporting legacy DOS crap: point of sale systems, etc. "Run your legacy DOS stuff in your browser with persistence in the cloud." You'd be surprised how much legacy DOS crap is out there.
[+] [-] g3|12 years ago|reply
[+] [-] dbancajas|12 years ago|reply
[+] [-] awy|12 years ago|reply
http://blog.alexanderdickson.com/javascript-nes-emulator-par...
Part 2 will be posted when it's done. :)
If you want to get something done much quicker, have a go at emulating the Chip-8 VM.
I also have a post, but it's less hand-holding than the first.
http://blog.alexanderdickson.com/javascript-chip-8-emulator
Good luck!
[+] [-] g3|12 years ago|reply
[+] [-] revelation|12 years ago|reply
[+] [-] JoshTriplett|12 years ago|reply
If you want to write one as a learning experience for how the platform you're emulating works and how an emulator could work in principle, you probably want to write an interpreter: find out how the platform boots, build something to start reading and interpreting instructions, start adding emulated hardware devices, and you'll get an increasingly functional interpreter.
For a start, you could ignore emulation of devices, and just write a CPU core that interprets instructions.
If you want to learn how modern (but still non-hardware-assisted) emulation works, read about how qemu's dynamic code translator and other JIT compilers work, and build a CPU emulator based on that.
[+] [-] dave84|12 years ago|reply
[+] [-] ghewgill|12 years ago|reply
[+] [-] joelanders|12 years ago|reply
[+] [-] s-macke|12 years ago|reply
Your emulator is impressive and especially fast. I think it took a long time for you to optimize it. I tried to start TinyCore, but it stops after decompressing the kernel. So still some work to do ;)
[+] [-] s-macke|12 years ago|reply
[+] [-] bcoates|12 years ago|reply
Also, swapping disks during the install might be an issue, I don't see a button...
[+] [-] g3|12 years ago|reply