Live data from Hacker News

Show HN: My x86 emulator written in JavaScript

copy.sh

51–60 of 194 posts

Re: Show HN: My x86 emulator written in JavaScript

#51
post #41

Earlier quoted context omitted.

I've found the bug. For now, try Chromium. I'll fix this tomorrow.

Thanks! What was the bug? I'd be interested. Also, any plans to implement GPF handling? I tried booting a test environment I have on it (which runs Python as part of the GRUB2 bootloader), but it failed primarily due to lack of support for trapping GPFs. (There are a few other issues I'd have to work around to make it work, but that's a major one that I can't easily work around.)

Chromium and Firefox send different key codes for `-` and `=` (see http://unixpapa.com/js/testkey.html).

Regarding GPFs: This is one of the few things that are not completely implemented yet, I'm working on figuring this out.

Re: Show HN: My x86 emulator written in JavaScript

#52

Very impressive. Interesting bug: I can't seem to type '-', '=', '+', or '_' into the Linux image. Missing '-' in particular makes it hard to run commands with options. Elaborate workaround: /root% eval eq$(dmesg | grep 'e820 update' | sed 's/.*) \(.\).*/\1\1/') /root% echo $eq = /root% eval dash$eq$(uname bad 2>&1 | grep Usage: | sed 's/.*\[\(.\).*/\1/') /root% echo $dash - /root% uname ${dash}a Linux (none) 2.6.34.…

This is the most soul-crushing category of bug, the kind which keeps me up all night, drinking. Build a skyscraper, and lock the keys inside for the ribbon cutting. Sorry pal you lost your funding Land on Mars, see an alien, but your camera is out of batteries and everybody back on Earth thinks you're a quack. Successfully perform open-heart surgery on a desert island, but muck up the stitches and cause a scar. Your…

The soul-crushing bugs are the ones where you run a program, and nothing actually goes actively wrong, but the program overall just doesn't behave quite like it does on the real hardware.

Simple defects where a key is being ignored on certain systems are usually quite easy to fix ;)

Re: Show HN: My x86 emulator written in JavaScript

#58
post #44
post #15

Earlier quoted context omitted.

At 2000 kIPS you may have a few generations of javascript engines to go before we get there. That's not meant to take away from this project - it truly is amazing what can be interpreted in the browser now.

Just for reference's sake this does vary a fair bit by computer and browser - mine never drops below ~8kIPS and runs mostly at ~15kIPS (and up to ~23kIPS). Whilst this is nothing like the several orders of magnitude required for more capable interactive behaviour, it does make my load times noticeably faster than those claimed on the page. :) (I'm Chrome on Linux, i7 4th Gen, incidentally)

I'm getting here > speed 1640kIPS on the old Nexus 7, don't you mean 8kkIPS?

(This value was the average while booting Linux)

Re: Show HN: My x86 emulator written in JavaScript

#59

I want to write an emulator as a learning experience. Any tips how should I start?

There are two sensible approaches: interpretation or dynamic translation.

If you want to write one as a learning experience for how the platform you're emulating works and how an emulator could work in principle, you probably want to write an interpreter: find out how the platform boots, build something to start reading and interpreting instructions, start adding emulated hardware devices, and you'll get an increasingly functional interpreter.

For a start, you could ignore emulation of devices, and just write a CPU core that interprets instructions.

If you want to learn how modern (but still non-hardware-assisted) emulation works, read about how qemu's dynamic code translator and other JIT compilers work, and build a CPU emulator based on that.

Re: Show HN: My x86 emulator written in JavaScript

#60

Very impressive. Interesting bug: I can't seem to type '-', '=', '+', or '_' into the Linux image. Missing '-' in particular makes it hard to run commands with options. Elaborate workaround: /root% eval eq$(dmesg | grep 'e820 update' | sed 's/.*) \(.\).*/\1\1/') /root% echo $eq = /root% eval dash$eq$(uname bad 2>&1 | grep Usage: | sed 's/.*\[\(.\).*/\1/') /root% echo $dash - /root% uname ${dash}a Linux (none) 2.6.34.…

I found that bug too. First thing I did was think, "a system restore is a page refresh away and I've always wanted to test the effects of this", then I attempted to type "rm -r /*".
Post reply on HN