Skip to content

migerh/dcpu16.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dcpu16.js

This is yet another assembler and emulator package for the DCPU16 processor as defined by notch/mojang, version 1.7 (see http://pastebin.com/raw.php?i=Q4JvQvnM). Try the live demo.

Usage

var result = DCPU16.asm(src);

Assembles the source code into a memory image (an array of bytes) which is accessible through the bc attribute. There's also some meta information returned in the meta property containing the address to line conversion object addr2line, the line to address conversion object line2addr and the entry point in entry.

var bc = result.bc;
var line = result.addr2line[0x1F];
var addr = result.line2addr[2];
var entryline = result.entry;  // equals result.meta.addr2line[0]

Please note that lines without a corresponding address (and vice versa) are undefined.

var PC = new DCPU16.PC([rom]);

Initializes a new DCPU16 PC. Optional parameter rom: An array of bytes.

var screen = new DCPU16.NE_LEM1802(PC);

Initialize a screen and connect it to the PC.

PC.load(rom);

Load the rom given as a memory image (an array of bytes).

PC.step();
PC.steps(i);

Executes one or i steps.

PC.start();
PC.stop();

Run the emulator until stop is called.

PC.clear();

Clear all registers and flags and reinitialize the RAM.

PC.ram[]

Access the ram. The registers and flags (A, B, C, X, Y, Z, I, J, SP, PC, EX, IA) can be accessed as properties of the ram:

var valueOfRegisterA = PC.ram.A;

Contributors

Acknowledgements

dcpu16.js uses test cases from krasin. Base64 encoding has been borrowed from Stuk's jszip.

Other projects/libraries used:

About

Yet another dcpu16 assembler & emulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages