The VM16 is a 16-bit virtual machine and a development environment with compiler, assembler and debugger.
It enables simulation of computers in the game Minetest and is capable of executing real binary code at a remarkable speed.
Browse on: GitHub
Download: GitHub
Documentation: GitHub
This mod is not very useful on its own. The real purpose for VM16 is to provide a programming environment to be easily integrated into other mods.
This mod consists of several parts:
- C files to be compiled and installed as LuaRocks package (the core VM)
- Lua files as API to the VM (low level interface)
- Programmer and server blocks as development environment to be used by other Minetest mods (high level interface)
- Some demo blocks showing the usage of programmer and server. These blocks have
to be enabled via
vm16_testblocks_enabled
(seesettingtypes.txt
)
Download the mod from GitHub,
extract the file from the ZIP archive and copy the folder vm16-master
into your Minetest mods
folder.
Change your directory to mods/vm16-master
and install the Lua library with:
luarocks make --lua-version 5.1
For Linux like systems, use:
sudo luarocks make --lua-version 5.1
The program output should look like this:
vm16 2.x-y depends on lua 5.1 (5.1-1 provided by VM)
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/vm16core.c -o src/vm16core.o
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/vm16lua.c -o src/vm16lua.o
gcc -shared -o vm16lib.so src/vm16core.o src/vm16lua.o
vm16 2.x-y is now installed in /usr/local (license: GPLv3)
For the installation of 'luarocks' (if not already available), see luarocks
To enable this unsafe
package, add 'vm16' to the list of trusted mods in minetest.conf:
secure.trusted_mods = vm16
Open the tab Settings -> All Settings -> Mods -> vm16 to enable the CPU/demo blocks or check settingtypes.txt.
The vm16 mod comes with the programmer, the file server, a computer, a lamp, and a switch block for training purposes. It can be used to get familiar with the programming environment.
- Craft the 5 blocks "VM16 Programmer", "VM16 File Server", "VM16 Demo Computer", VM16 On/Off Switch" and "VM16 Color Lamp".
- Place "VM16 Demo Computer", VM16 On/Off Switch" and "VM16 Color Lamp" next to each other. The computer searches for I/O blocks in an area with a radius of 3 blocks.
- The switch is used as input block for the computer, the lamp as output block.
- Give lamp and switch an I/O address. For the provided example, address '1' is used for both blocks.
- You can add further I/O blocks for you own programs with other addresses.
- Place the server anywhere.
- Connect the programmer with server and CPU by left-clicking with the wielded programmer on server and CPU block.
- Place the programmer anywhere.
- Press the "Init" button to initialize the computer.
- Now double-click on the file "example1.c" to open the edit.
- Click on "Debug" to start the debugger.
- Click on "Run" to execute the program. The lamp block should now change its color
None. Optional: default, basic_materials (for demo CPU and blocks)
Copyright (C) 2019-2023 Joachim Stolberg Licensed under the GNU GPLv3 (See LICENSE.txt)
- Improve compiler (switch/case, functional blocks, ...)
- Compiler: Improve 'goto' support (according to: https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html)
- Core VM: Fix buffer size check bug
- API: Add functions
vm16.get_vm
andvm16.set_vm
- Programmer: Add SD Card functionality
- Compiler: Enable jump tables via:
var tbl[] = {func1, func2}; ... tbl[idx]();
- Compiler: Add >= and <= operators
- Compiler: Add constant expressions
- Compiler: Add sizeof operator
- Compiler: Add static constants
- Add file popup menu to the debugger
- Fix some debugger bugs
- Add support for function-local arrays (core, asm, compiler, debugger)
- Improve standard library (memset, itoa, halt,...)
- Fix some minor bugs
- Compiler: Add support for the '&' reference operator
- Add core functions
write_ascii_16
for 16-bit/compact strings
- Compiler: Add octal number and string escape sequence support
- Add break, continue, and goto statements to the compiler
- Add storage compatible
hash_node_position
/get_position_from_hash
functions
- Add terminal mode to the debugger
- Fix server2 bug
- Add 'if ... else if' functionality to the compiler
- Add branch detection to compiler and debugger
- Fix some debugger bugs
- Add core functions
vm16_read_mem_as_str
andvm16_write_mem_as_str
- Add register C to
get_io_reg()
- Remove
vm16.register_sys_cycles
function - Add ASM startup code to compiler options
- Prepare for the beduino mod
- Fix some bugs
- Add static variables and functions
- Add strcmp and memcmp functions
- Fix some bugs
- Change stdout from output(0,...) to system(0,...)
- Add logical 'and' and 'or' operators
- Add 's[]' type for strings
- Fix some bugs and improve demo CPU
Work in progress!
- Simplify and standardize compiler and assembler output
- Enable import of C and ASM files in C files
- Update and improve debugger (add step-in and step-out buttons)
- Add more example code to the demo CPU
- Many improvements and bug fixes
Work in progress!
- Expand compiler with arrays and pointers
- Expand compiler with strings and chars
- Expand compiler with constants and inline assembler
- Update debugger
- Bug fixes
Work in progress!
- Core: Add TOS register for the debugger
- Add VM16 Programmer and VM16 File Server
- Programmer provides compiler, debugger, and variable watch window
- Core: Add BP register and [X+n], [Y+1] opernand types
- ASM: Adapt assembler for the new instructions
- Doc: Adapt manuals for the new instructions
- Add BLL compiler prototype (B like language), is unused so far
- ASM: Add support for namespaces (for macro ASM)
- ASM: Allow 3-word instructions (needed by BLL)
- Core: Fix bug in branch instructions
- Core: Change memory size calculation
- Rework the I/O API and blocks
- Docu: Update vm16_api.md
- Core: Change BRK instruction
- API: Add breakpoint functionality
- CPU: Add breakpoint functionality
- C-core: Add REL2 addressing mode (as replacement for wrong REL implementation)
- Asm: Fix RIP addressing bug (reported by DS)
- Asm: Add 'namespace' and 'global' keyword to enable local and global labels
- Docu: Updates
- 2022-02-19 v2.4 * Allow 0 for memory size (= 512 words), add computer demo blocks
- 2021-08-30 v2.3 * Improve documentation
- 2021-01-07 v2.3 * Update testing modes
- 2020-12-31 v2.3 * Change vm16_read_h16() parameters
- 2020-12-29 v2.2 * Add breakpoints and read/write_bin functions
- 2020-12-25 v2.1 * Add function 'set_cpu_reg'
- 2020-12-02 v2.0 * Switch to mod storage for VMs
- 2020-11-30 v1.3 * Add functions read_h16/write_h16
- 2020-11-29 v1.2 * Complete rework, Add test nodes
- 2020-11-21 v1.1 * First commit as LuaRocks project