5 ms·
JSLinux rewritten to be human readable, deobfuscated and annotated
- szc 14y agoFabrice is a 2 time winner of the IOCCC http://www.ioccc.org/winners.html#B http://www.ioccc.org/winners.html#B.
- jscheel 14y agoLooking at this code really makes me wish I had taken an OS design class in school.
- ern 14y agoDid the person doing this get his permission? Seems unclear from the readme. The readable source code of the JS PC emulator itself is not yet available. At this point, any mirroring or redistribution of the code needs my explicit permission http://bellard.org/jslinux/faq.html http://bellard.org/jslinux/faq.html
- EwanToo 14y agoYou're probably right, but it's been up over a year now that I can see, the code commits are from Dec 2011: https://github.com/levskaya/jslinux-deobfuscated/commits/master/term.js https://github.com/levskaya/jslinux-deobfuscated/commits/mas... So by now it's likely that Fabrice Bellard is aware of it
- Breakthrough 14y agoAgreed that he should have gotten permission before publicly hosting this, but looking through some of what he's done, I'm pretty impressed with what I've seen so far. He's clearly doing this to learn, and some of the comments in the source code I read through reflect this as well. I always loved showing people JSLinux, they'd flip out at how it was a joke or not real or something... Then I'd do a "Hello, world!" type example in C and their eyes would open wide, knowing that I just compiled and ran an x86 program under a Javascript emulator in my browser.
- chjj 14y agoDefinitely the first thing that came to my mind. I don't like that he is not respecting the original author's license. We're all used to opensource and freedom to redistribute here, but when someone licenses something a different way, we should still respect it. Bellard is a reasonable man. I asked him for permission to release my web terminal (https://github.com/chjj/tty.js https://github.com/chjj/tty.js), (which was originally based on his jslinux terminal), under the MIT license, and he did give me permission. All it takes is the courtesy to ask and to state your intentions with it. Hopefully thats what the poster did here, but it does seem unclear.
- recuter 14y agoFor anybody who wants to study another, freely available, take on this (made by an HN member): http://www.ubercomp.com/jslm32/src/ http://www.ubercomp.com/jslm32/src/ https://github.com/ubercomp/jslm32 https://github.com/ubercomp/jslm32 There's also a nice Quora answer (I don't like linking to them but what the hell) to get the ball rolling on the basics: http://www.quora.com/Emulators-computing/How-does-bellard-org-jslinux-work http://www.quora.com/Emulators-computing/How-does-bellard-or...
- deleted 14y ago
- peterkelly 14y agoFabrice Bellard is smart enough that he can probably work directly with obfuscated code without it having to go through a separate translation process. The "obfuscated" source could in fact be the original :)
- vanderZwan 14y agoCould that be a byproduct of doing much assembly?
- nimrody 14y agoWhile this may seem like a joke when referring to this size of code, some people actually write this way: http://nsl.com/papers/origins.htm http://nsl.com/papers/origins.htm (Arthur Whitney's initial implementation of "J")
- derekp7 14y agoThe example I use is: is it easier to read "a + b", or "a plus b"? In many cases, what looks like obfuscation is just shorthand notation.
- AnthonBerg 14y agoThe appropriate counterexample here is which is easier to read, "a plus b" or "aplusb"? :)
- qznc 14y agoThat is not "obfuscated", but rather J-style. The rationale is: To write a J interpreter/compiler you need to know J. If you know J, then J-style C is easy to work with.
- euroclydon 14y agoQuestioning the wisdom of saying this on the public internet, but the first line of the first file has caught me up. What is the purpose of this function, from the clock emulator: function formatter(a) { return ((a / 10) << 4) | (a % 10);}
- mikeash 14y agoLooks like a converter to BCD. It'll take e.g. 42 and turn it into 0x42. No clue why this would be necessary, but that looks like what it does.
- sounds 14y agoYes, some links on why BCD: http://wiki.osdev.org/RTC http://wiki.osdev.org/RTC http://wiki.osdev.org/CMOS#Format_of_Bytes http://wiki.osdev.org/CMOS#Format_of_Bytes
- mikeash 14y agoThanks for the links. And, holy crap is PC hardware bizarre.
- Someone 14y agoBCD isn't _that_ bizarre. Many architectures had and have instructions for BCD arithmetic: x86: http://en.wikipedia.org/wiki/Intel_BCD_opcode http://en.wikipedia.org/wiki/Intel_BCD_opcode 68k: http://meseec.ce.rit.edu/eecc250-winter99/250-1-20-2000.pdf http://meseec.ce.rit.edu/eecc250-winter99/250-1-20-2000.pdf 6502: http://www.6502.org/users/dieter/bcd/bcd_0.htm http://www.6502.org/users/dieter/bcd/bcd_0.htm 6800: http://fundamentals-digital-electronics.blogspot.com/2010/09/motorola-6800-eight-bit-microprocessor.html http://fundamentals-digital-electronics.blogspot.com/2010/09... Several others, such as Power6 and Sparc64: http://speleotrove.com/decimal/ http://speleotrove.com/decimal/ (also shows this is is both still useful today)
- alexkus 14y agoWhy don't you try it for a bunch of input values and find out yourself? Hint: 0->0, 1->1, ..., 9->9, 10->16, ..., 19->25, 20->32, 29->41, 30->48, ...
- martinced 14y agoThere are mere mortal programmers, there are geniuses and then there's Fabrice Bellard. In french slang: "Tu peux pas test". Go read the list of Open Source project he's done: it's a humbling experience (even for those who managed to make it big with their startups).
- hwh 14y agoWhen I did a little project using jslinux, just for fun on the Chaos Communication Camp 2011, I contacted Fabrice about it. And he was helpful and gave permission to do with the code what I planned to do (I wrote a network hardware emulation, the corresponding Linux driver and a central server, so I could connect to the remotely running Linux instances in peoples' browsers). It's allowed to discuss Fabrice's code, it's allowed to post a de-obfuscator software tool, but it's certainly not permitted to publicize a derivate without his consent. It's plain respect for intellectual property.
- SeanDav 14y agoI see stuff like this (The original JSLinux, not the de-obfuscated one) and am simply in awe. Guys like Fabrice Bellard are on another level completely. Someday, I am going to have to produce an emulator, just to see how it is done and to try prove that part of me that thinks maybe I am just not good enough, wrong.
- zjiekai 14y agoThis may be helpful http://www.youtube.com/watch?v=y71lli8MS8s http://www.youtube.com/watch?v=y71lli8MS8s
- zellyn 14y agoI am working on one now (Apple II, in go). It turns out it is not that difficult. You just have to be persistent, and be willing to do a lot of reading. Although I don't have a ton of free time at the moment, I would be happy to help people get started.
- exim 14y agoPardon my ignorance, but besides being a quite tedious task to write an emulator, what are genius or other similar aspects of it? I mean, AFAIK you just need to closely follow the SPECS.
- calleskonto 14y agoBellard has updated his site since this was made. The Newer version has an IDE disk.