alexbrjo/MolassOS

View on GitHub
src/asm/MolassesASM.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Compiles Intel 8080 assembly mnemonics to machine code
 */
var MolassesASM = function() {

    /** The last compilation */
    var last = null;

    /**
     * Gets the last compilation
     * @return {Object} the last compilation
     */
    this.getLast = function () {
        return last;
    };

    /**
     * Compiles assembly into an executable binary
     * @param {String} src the source code
     * @param {Number} size the size in bytes of the executable (optional)
     * @return {Object} results of compilation
     */
    this.compile = function (src, size) {
        // removes comments, converts values and literals to hex
        var preprocessed = preprocess(src);
        // assemble into binary
        last = assemble(preprocessed.output, size);

        return last;
    };

};