lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sun, Jan 8, 2012 at 16:31, David Given <> wrote:
> On 08/01/12 21:10, Reuben Thomas wrote:
>> On 8 January 2012 21:09, David Kolf <> wrote:
> [...]
>>> Somebody already wrote a PC emulator in JavaScript. ;-)
>>> <>
>> And with something like Javascript's typed arrays extension for Lua
>> you could do it in Lua.
> I should point out that most of the magic in Fabrice Bellard's emulator
> is that it's *not* emulating x86 code; it's dynamically recompiling it
> into Javascript, and then running the Javascript directly. (It builds on
> a lot of the same logic as qemu.)
> The same trick would work just as well in Lua, and LuaJIT's ffi even
> gives the fast byte arrays to make it all efficient.
> The massive amounts of work to actually make it all happen is left as an
> exercise for the reader...
> --
> ┌─── ───── ─────
> │
> │ "Never attribute to malice what can be adequately explained by
> │ stupidity." --- Nick Diamos (Hanlon's Razor)

mm, I've thought about recompiling into Lua code, but that's something
to experiment later once I get basic interpretation working. I'm
mostly just curious how slow it'll be interpreting in Lua. Of course
memory will be stored in a fast byte array. (I wrote such a module for
plain Lua a while back.)

Sent from my toaster.