LuaASM is a lightweight assembly-like language interpreter written in Lua. It supports a variety of instructions for arithmetic, flow control, stack operations, I/O, and more. LuaASM is designed to be extensible and includes features like debugging, TUI (Text User Interface), and MNI (Micro Native Interface) for advanced functionality.
- Assembly-like Language: Supports basic instructions like
MOV
,ADD
,SUB
, and more. - Flow Control: Includes
JMP
,CALL
,RET
, and conditional jumps likeJE
,JL
, etc. - Stack Operations: Push and pop values to/from the stack.
- I/O Operations: Output strings or values to stdout or stderr using
OUT
. - Data Definition: Define strings in memory using
DB
. - Debugger: Step through code, inspect registers, memory, and stack.
- TUI Mode: Visualize code execution, registers, and stack in a terminal-based UI.
- MNI Support: Extend functionality with native system calls or external libraries.
- Lua 5.4 or later installed on your system.
- A terminal or command prompt to run the interpreter.
- Clone the repository or copy the files into a directory.
- Ensure the following directory structure:
LuaASM\ ├── interp.lua ├── debug.lua ├── tui.lua ├── root\ │ └── stdio\ │ └── print.masm ├── main.masm └── README.md
To execute a LuaASM program, run the following command:
lua interp.lua main.masm
Here’s an example program (main.masm
) that outputs "hello world":
#include "stdio.print"
lbl main
mov RAX 1
mov RBX 100
db $100 "hello world"
call #printf
hlt
Start the interpreter in debug mode:
lua interp.lua main.masm --debug-cli
In debug mode, you can step through instructions, inspect registers, and more. Type h
in the debugger for a list of commands.
To enable the Text User Interface (TUI) for debugging:
lua interp.lua main.masm --debug
Then, in the debugger, type:
tui start
For a complete list of supported instructions, see Instruction Set Documentation.
interp.lua
: The main interpreter.debug.lua
: Debugger for stepping through code and inspecting state.tui.lua
: Text User Interface for debugging.root/
: Contains standard library files (e.g.,stdio.print
).includes/
: Placeholder for Lua-based extensions.main.masm
: Example program.
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License. See LICENSE
for details.