
Mini x86 – An x86 documentation, decompiler and emulator in pure JS - matt_d
https://github.com/xem/minix86
======
xem
Hi 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
TLDR:

* 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.

------
ggambetta
This 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)

------
jaclaz
It 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
it 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
Ok, 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
I 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
In 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

------
if-loop
This 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
I 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.)

------
qz_
Why use Javascript for this?

~~~
tracker1
Atwood'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/)

