How does Linux emulator in Javascript by Fabrice Bellard work

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

Today I had a jaw dropping moment, when I saw Linux emulator in Javascript: http://bellard.org/jslinux/ http://bellard.org/jslinux/

It compiles C programs, it has vi and emacs, it supports all shell commands, etc etc.

How does it work?

Answers

At first, I also thought this is just a terminal emulator connecting you to a VM but it isn t. If you watch the network connections, you can see that, after bootup, no data is transmitted anymore.

So it s real.

A CPU is not something magic; in fact all it does is read bytes from memory and modify the RAM in accordance to what the commands mean.

In this case, the CPU emulator is based on the qemu code. What he does is he creates an array of functions where the index is the next byte at the PC (program counter).

Now all you need is a simple linux distribution that doesn t need any exotic CPU commands like floating point arithmetic or MMX code and voila.

What s interesting is the speed of the beast. The whole thing is a bit sluggish but then, it s JavaScript in a browser.

Conclusion: Impressive. Can t wait to see a C64 emulator :-)

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/6030407/how-does-linux-emulator-in-javascript-by-fabrice-bellard-work

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils