https://github.com/noracodes/mlem_asm
An assembler for the MLeM VM.
https://github.com/noracodes/mlem_asm
Last synced: 12 months ago
JSON representation
An assembler for the MLeM VM.
- Host: GitHub
- URL: https://github.com/noracodes/mlem_asm
- Owner: NoraCodes
- Created: 2017-04-04T19:22:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-02T02:38:20.000Z (over 7 years ago)
- Last Synced: 2025-02-05T01:25:01.434Z (over 1 year ago)
- Language: Rust
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mlem-asm
[](https://crates.io/crates/mlem-asm)
[](https://docs.rs/mlem-asm/)
This crate provides an assembler for the [MLeM](https://github.com/leotindall/mlem) virtual machine.
It assembles codes like this:
```
; a simple program that prints some ASCII characters
; from space to tilde
move 96 R7 ; 0 Set the counter
move 31 R0 ; 1 Set the initial value to output
add R0 1 ; 2 Increment the value to output
output R0 ; 3 Output that value
sub R7 1 ; 4 Update the counter
jnz 2 R7 ; 5 Loop if the counter is not 0
halt ; 6 Allow the program to complete successfully
```
This is, in fact, the contents of `test.asm`. The provided front-end can be used to
assemble and run this program, thus:
```
$ cargo run r test.asm
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/examples/mlem-asm r /home/leo/Projects/mlem-asm/test.asm`
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
Halt
```
Using mlem-asm, this program is assembled into the following hex (in test.bin):
```
d9d9 f787 8302 8203 1860 8200 0783 0282
0318 1f82 0000 8305 8200 0082 0301 8203
8200 0083 0682 0007 8203 0183 0982 0302
8200 070c
```