ufhunter.blogg.se

Mc68000 javascript emulator
Mc68000 javascript emulator






mc68000 javascript emulator

To answer your question, I have been programming for 7 years, but I think that you should be able to write a simple x86 interpreter after 6 months of learning JavaScript or even less. If you are interested, I can specify the details of the implementation, basic CPU architecture or anything else concerning this project in chat or a blog post :) I wanted a little more robustness, so I'm using the PEG.js parser generator ( ), which generates the parsing code for you if you specify the grammer (rules for how the input looks like). Luckily assembly has very little structure and with a bit of effort it could be parsed line-by-line by simple regular expressions. Probably the hardest thing to do (if you never wrote a compiler/interpreter before) is parsing the source code. There are some subtleties if you want to emulate the CPU very precisely, but otherwise it's just a matter of updating the arrays by executing simple operations on them. It can be translated into the following JS code:

mc68000 javascript emulator

1-5 lines of JS (if you ignore all the nitty-gritty details of vector and string instructions etc.).įor example if you encounter the instruction Each instruction can be translated to max. The assembly instructions are very simple, they usually just copy a few bytes from place A to place B or do a simple arithmetic operation (addition, subtraction, multiply etc.). You then go over the instructions and execute them one by one, changing the contents of the three arrays. The whole thing can be represented with three arrays (memory, stack and registers). You have to know a little bit about the (von Neumann) architecture of the CPU (registers, instruction pointer, memory, stack), but you don't have to go deep to create something like this. If you want to emulate a whole OS that's another story :-) There are probably many bugsĪnd missing features, if anyone is interested, create an issue or send a PR here.Ĭreating a x86 interpreter in JS is actually quite simple (if you don't care about performance and/or completeness). Nowadays I would probably write it in React,īut the UI isn't very complicated, so it doesn't matter much. I wrote it two years ago in Typescript and Angular 4. (also I wanted to write a simple assembly emulator :) ). Tools ( 1, 2), but they were either not very user friendly or too complicated for my liking My tool is not by any means complete, but for simple/short programs, you should be able toĬopy/paste it, compile it with e.g. It was inspired by this simulator, which is really nice, but I wanted something that is more close to x86 and doesn't just have 4 registers. It also has a simple console where you can print stuff. It has syntax highlighting, breakpoints and allows step-by-step debugging and inspecting It can be used for simple assembly experiments

mc68000 javascript emulator

I have created a web-based emulator and debugger of x86 assembly,








Mc68000 javascript emulator