| Crates.io | dcpu16 |
| lib.rs | dcpu16 |
| version | 0.4.0 |
| created_at | 2015-06-13 02:36:05.620946+00 |
| updated_at | 2016-12-18 00:20:34.083802+00 |
| description | DCPU-16 assembler, disassembler and emulator |
| homepage | |
| repository | https://github.com/gustavla/dcpu16 |
| max_upload_size | |
| id | 2368 |
| size | 194,978 |
DCPU-16 assembler, disassembler and emulator written in Rust.
DCPU-16 is a CPU specification from the never-completed game 0x10c by Notch (from 2012). More info about the DCPU-16:
To run DCPU-16 programs with hardware devices (such as a monitor, keyboard, etc.), use:
The DCPU-16 is feature complete and ready for use:
SET A, 0x8000+100*3)Run cargo build --release and add dcpu16/target/release to your PATH:
$ dcpu16-assembler program.asm -o program.bin$ dcpu16-disassembler program.bin$ dcpu16-tokenizer program.bin$ dcpu16 -p program.binApart from providing binaries, this crate can also be used as a library and embedded into other programs. An example of this can be seen in dcpu16-gui.
Some extensions (possibly temporary):
--- Special opcodes: (5 bits) --------------------------------------------------
C | VAL | NAME | DESCRIPTION
---+------+-------+-------------------------------------------------------------
0 | 0x13 | OUT a | prints a null-terminated string located at a in memory
0 | 0x14 | OUV a | prints a value in decimal and then a newline
---+------+-------+-------------------------------------------------------------
Since hardware is not supported, you can use OUT to print to regular standard
output. Another temporary behavior is that the CPU is terminated if it reads a
0x00 instruction.
Extensions to the assembler:
-- Assembler instructions ------------------------------------------------------
FORMAT | DESCRIPTION
--------------+-----------------------------------------------------------------
DAF c, v | DATA FILL - repeats a value a certain number of times
| c (count) and v (value) must be numerical literals
| e.g. DAF 256, 0xffff ; Fill 256 words with -1
--------------+-----------------------------------------------------------------
Save the following as prog.asm:
OUT hello ; Print the string defined at 'hello'
DAT 0 ; This will terminate the program
:hello DAT "Hello World!\n", 0
Assemble the program:
$ assembler prog.asm -o prog.bin
Run it:
$ emulator prog.bin
Hello World!