ChunkBake: A Lua 5 Assembler
ChunkBake is a line-oriented assembler
for Lua 5 virtual machine instructions. It produces a binary chunk from
assembly code, which can then be loaded and run on a Lua 5 virtual
machine. ChunkBake is an educational
tool; you'd probably won't be
writing substantial Lua applications in assembly language form (but if
you are, please pass me some of the stuff you're smoking... :-)) The
ChunkBake bears a resemblance to
ChunkBake is written in Lua so that it is portable and easy to hack.
Binary chunks that are generated can be customized with different data
and field sizes and number types, so if you want to produce
non-standard chunks from assembly code, this is the tool for you. You
can break a lot of rules as well, and do things the Lua 5 code
generator won't do. If
you want a smaller assembler, a lot of code can be ripped out.
luas assembly code, with
The front end was written to accomodate a variety of coding styles,
e.g. registers can be written as 0, R0 or $0.
ChunkBake currently works only for Lua 5.0.2 instructions. Processing
is brisk so there shouldn't be speed issues. For pre-1.0 releases, the
syntax is open for fixes or changes. If there are better ways to write
some of the assembly syntax, or if there is a defacto standard for such
things, the assembler syntax MAY CHANGE for pre-1.0 releases.
Main links: ChunkBake project page
on LuaForge | File
(90KB zip). Win32 binary (127KB zip) available as well.
- [0.7.0] Major update:
- General Lua-style expressions for
most values and operands.
- Equate (.equ) directive, using the
global symbol table.
- Unified symbol namespace, added a
global symbol table.
- Number conversion supports positive
and negative infinity.
- Fixed instruction encoding bug for
setupval and getupval.
- Range operator changed from '..' to
'...' to accommodate expressions.
- Added additional warning and error
messages for certain instruction patterns.
Constant declaration and
operands can use nil; added a few more examples;
basic reference documentation
This is a preliminary release.
Rudimentary but complete. Many bugs have been ironed out by the test
script. Quite usable.
- If you are looking for a disassembler for Lua 5 binary chunks,
you can try ChunkSpy,
which complements ChunkBake and diassembles to VM instructions, or LuaDec by Hisham
disassembles to Lua source code.
- If you want to learn more about the instruction set of the Lua 5
virtual machine, you can read "A No-Frills
Introduction to Lua 5 VM Instructions."
- ChunkBake is pretty usable at the moment, as it is checked using
over 400 test cases in a separate automatic test script. Many bugs have
- Generated binary chunks are targeted to Lua 5.0.2, they will not
work on Lua 5.1wk5. Support for Lua 5.1 is planned (ChunkSpy already
supports Lua 5.1 work 5.)
- A reference manual for ChunkBake is included in the download, as
are several examples based on the simple test programs found in the
directory of Lua 5.0.2.
- ChunkBake now has expressions, but some functionality is still
missing, like macros and include files, so you can't really do very
complex programs with the assembler
yet. For more on missing stuff, see the TODO file in the download.
Thanks to the LuaForge team for
hosting this material. This page was written on SeaMonkey.
developed using the SciTE editor.
This page Copyright
© 2005-2006 KHMan. See the scripts for
license information (MIT-style).
Canonical URL: http://chunkbake.luaforge.net/