5 ms·
Mini x86 – An x86 documentation, decompiler and emulator in pure JS
- if-loop 10y agoThis is not a decompiler but a disassembler. See[0] for futher details. [0]: https://en.wikipedia.org/wiki/Decompiler https://en.wikipedia.org/wiki/Decompiler
- userbinator 10y agoI was also a bit disappointed to see that, since a decompiler is far more interesting (and complex). But decompilation involves disassembly (in particular, one that follows the execution flow) so at least it's a start... As discussed at https://news.ycombinator.com/item?id=9321698 https://news.ycombinator.com/item?id=9321698 , "write a disassembler at least once" is a good exercise and not particularly hard even for x86, because a lot of the instructions follow common patterns (easier to see in octal.)
- jaclaz 10y agoIt seems nice, but the actual disassembler doesn't seem to work here: http://xem.github.io/minix86/decompiler.html http://xem.github.io/minix86/decompiler.html is there any specific browser or OS requisite? The "choose file" button works, but then nothing happens, and all the "built-in" examples buttons do nothing.
- xem 10y agoit should work on any modern browser. Warning though, the url has changed a little: see https://github.com/xem/minix86 https://github.com/xem/minix86
- jaclaz 10y agoOk, still this: https://xem.github.io/minix86/src/disassembler.html https://xem.github.io/minix86/src/disassembler.html doesn't work for me, maybe by "modern" you mean a current Chrome or Firefox. I tested it with QTweb, Chrome 43 and Opera (Presto), certainly not the most "mainstream" or "popular" or "latest" browsers around, still I find no real reason why the thingy shouldn't work with them.
- xem 10y agoI just tested on Chrome, Firefox and Edge (W10) and it works fine everywhere. Do you have an error showing up in your console or something?
- jaclaz 10y agoIn Chrome 43 (Ok, Iron Browser) I get two errors: Uncaught SyntaxError: Unexpected token =>helpers.js:10 Uncaught SyntaxError: Unexpected token =>demos.js:2 Basically the first two actual instructions are not parsed correctly. In Opera (12.15) I have three errors: Syntax error at line 10 while loading: expected expression, got '>' var to16 = (n, l) => { -------------------^ Linked script compilation helpers.js Syntax error at line 38 while loading: invalid character after numeric literal: 'b'. n = b & 0b1111; -------------^ Linked script compilation disassembler.js Syntax error at line 2 while loading: expected expression, got '>' hello.onclick = e => { -------------------^ Linked script compilation demos.js
- ggambetta 10y agoThis is fantastic! I wish this existed back when I did my emulator-baked remakes experiment [1]. May use this as the foundation for the next iteration! [1] http://gabrielgambetta.com/remakes.html http://gabrielgambetta.com/remakes.html
- deleted 10y ago[deleted]
- userbinator 10y agothe real challenge is implementing the sheer amount of opcodes If you want to write the most compact emulator, not necessarily the fastest, you can use the octal structure of the instruction encoding to condense your code greatly. https://news.ycombinator.com/item?id=13045558 https://news.ycombinator.com/item?id=13045558 The first ~1/4 of the first-page opcode space is ALU ops, the next 1/4 is inc/dec/push/pop reg. The second half is less regular but you can still find big chunks that can be taken care of with only a few lines of code (e.g. 9x are exchanges with eAX, Bx are all immediate moves.)
- xem 10y agoIndeed, the final goal is to make it compact too. Thanks for the link! Another source of inspiration for compactness is: https://github.com/adriancable/8086tiny https://github.com/adriancable/8086tiny
- xem 10y agoHi guyz, I'm the author of this project, but not the author of this post. Indeed the project is very incomplete and indeed it's "disassembler" - not "decompiler" :) I plan to talk about it on HN when I'm satisfied with the results (and when the emulator starts outputting things)... today was a little early. Thanks though for the upvotes and the kind remarks! Cheers and happy 2017!
- rounce 10y agoTLDR: * There is no emulator * This appears to be a work-in-progress project. * The 'decompiler' is actually a disassembler * Only supports a tiny subset of opcodes.
- qz_ 10y agoWhy use Javascript for this?
- tracker1 10y agoAtwood's Law [1] ... Mainly because the web browser is the single most broadly available interface with JS being the most accessible language to use in that interface. There are definitely other JS x86 emulators out there. JS isn't the fastest available, but it's far closer to run everywhere. [1] https://blog.codinghorror.com/the-principle-of-least-power/ https://blog.codinghorror.com/the-principle-of-least-power/
- xem 10y agoMainly for fun and because I like this language. Also, my goal is to let people drop a x86 demo in their browser and just watch it play or interact with it without any other tool.