lua-users home
lua-l archive

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


Joe Wilson wrote:
> The LuaJIT website said to post questions here. 
> I hope it's the right place.

Well, this is to avoid fragmenting the Lua community since most
questions are really general questions about Lua. But specific
questions may be better answered by mail.

> DynASM appears to take x86 opcodes as input, generates some sort 
> of intermediate non-CPU-specific representation, and then creates 
> machine code for x86.

Nope. The intermediate representation _is_ machine code, just
with some escape codes mixed in. These allow for dynamic
features, such as branching or patching offsets and immediates
with variables and struct offsets from C.

> Even if DynASM *could* target other CPU architectures (which I don't 
> think it does yet), such as ARM or MIPS, would the DynASM input still 
> remain this x86-like opcode syntax?

Not really. The opcodes and their encodings are machine-specific,
but the underlying core of DynASM is generic. The backend for
emitting the machine code from the intermediate code is
machine-specific, too (to keep it short, currently < 2 KB).

For a port to a different architecture, one would have to write
replacements for the machine-specific parts (dasm_x86.lua and
dasm_x86.h). This would imply different opcodes of course, but
generic features like macros or conditionals would stay the same.

> The design choice of using x86 opcode syntax for DynASM's input - was 
> it somewhat arbitrary?  Was it used because it was a relatively simple
> machine model with a small number of registers?

Well, the box under my desk runs x86 machine code. :-)

And, no, I wouldn't use x86 syntax for a generic machine model
(not that DynASM does this).