ChunkBake: A Lua 5 Assembler
Introduction
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
syntax of
ChunkBake bears a resemblance to luas assembly code, with
differences.
The front end was written to accomodate a variety of coding styles,
e.g. registers can be written as 0, R0 or $0.
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.
ChunkBake currently works only for Lua 5.0.2 instructions. Processing
speed
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.
Download
Main links: ChunkBake project page
on LuaForge | File
releases
Latest
version: ChunkBake-0.7.0
(90KB zip). Win32 binary (127KB zip) available as well.
What's new?
- [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.
- [0.6.0]
Constant declaration and
operands can use nil; added a few more examples;
basic reference documentation
completed.
- [0.5.0]
This is a preliminary release.
Rudimentary but complete. Many bugs have been ironed out by the test
script. Quite usable.
More Stuff
- 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
Muhammad, which
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
been squashed.
- 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
/test
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.
Acknowledgements
Thanks to the LuaForge team for
hosting this material. This page was written on SeaMonkey.
ChunkBake was
developed using the SciTE editor.
This page Copyright
© 2005-2006 KHMan. See the scripts for
license information (MIT-style).
Last
Revised: 2006-11-04.
Canonical URL: http://chunkbake.luaforge.net/