Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
105
rated 0 times [  110] [ 5]  / answers: 1 / hits: 20604  / 13 Years ago, tue, may 17, 2011, 12:00:00

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



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



How does it work?


More From » linux

 Answers
9

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 :-)


[#92198] Monday, May 16, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;