Mini x86 – An x86 documentation, decompiler and emulator in pure JS
github.com
github.com
Thanks though for the upvotes and the kind remarks!
Cheers and happy 2017!
* 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.
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.
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.
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
Deleted comment
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
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.)
As discussed at 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.)
[1] https://blog.codinghorror.com/the-principle-of-least-power/