Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.
/ opcoder Public archive

A utility for converting LEGv8 mnemonics into instructions in hexadecimal format.

License

Notifications You must be signed in to change notification settings

ZhongRuoyu/opcoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Opcoder

Opcoder is a utility for converting LEGv8 mnemonics into instructions in hexadecimal format which supports basic syntax error detection. It is modified from Dr K. G. Smitha's OPCoder.

Usage

To use it in your JavaScript scripts, see the example below:

import { convertLines } from "./opcoder.js";

const input = `ADD X5, X5, X6 // ADD
LDUR X5, [X2, #0] // LDUR
CBZ X7, #3 // CBZ
B #4 // B
STUR X5, [X2, #2] // STUR`;

console.log(convertLines(input));

To embed this in an HTML page, do this:

<script type="module">
    import { convert } from "./opcoder.js";

    function convertLines(lines) {
        return lines
            .split("\n")
            .map(line => (line.trim().length !== 0)
                ? `${convert(line).toUpperCase()} // ${line}`
                : line);
    }

    document.getElementById("input").addEventListener("input", e => {
        const lines = document.getElementById("input").value;
        document.getElementById("result").value = convertLines(lines).join("\n");
    });
</script>

A working example is available here.

License

Copyright (c) 2022 Zhong Ruoyu. Licensed under the MIT License.

About

A utility for converting LEGv8 mnemonics into instructions in hexadecimal format.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project