GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tekord/cpp-opcode-generator: A python script for generating enums with opcode constants based on YAML file definition

BranchesTags
Open more actions menu

Latest commit

 

History

29 Commits
29 Commits

Folders and files

NameName
Last commit message
Last commit date
templates
templates
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
main.py
main.py
 
 
opcodes.example.yaml
opcodes.example.yaml
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Opcode constant generator for C, C++ and Rust programming languages

A python script for generating enums with opcode constants based on YAML file definition. It may be useful for virtual machine developers. Defining opcodes in external file instead of direct C++/Rust enum has some advantages:

  1. It is easier to read. Definition file contains only relevant information, no C++ code.
  2. You can automate a documentation building.
  3. Opcode definition is isolated from your virtual machine implementation, so you can use it in non-C++ implementation (of course you'll have to modify this script a little bit).

Written on Python 3.

Installation

Execute the following command to install dependencies:

pip install -r requirements.txt

Usage

Copy the opcodes.example.yaml file to your application's folder, define all the opcodes you need in this file. Then run the script with the following arguments:

python main.py <opcode-list> <language> [--output path/to/file]

where opcode-list is a path to file with opcodes (.yaml file); language is one of the following options: c, cpp, rust; --output specified the output file path. If the output option is not provided then result will be printed to the standard output.

The result may look like this:

enum _GeneratedOpCodes {
    OPCODE_NOP = 0x00,
    OPCODE_B = 0xA0,
    OPCODE_BZ = 0xA1,
    OPCODE_B_FALSE = 0xA1 /* alias for BZ */,
    OPCODE_B_ZERO = 0xA1 /* alias for BZ */,
    OPCODE_B_NULL = 0xA1 /* alias for BZ */,
    OPCODE_BNZ = 0xA2,
    OPCODE_B_TRUE = 0xA2 /* alias for BNZ */,
    OPCODE_B_NOT_ZERO = 0xA2 /* alias for BNZ */,
    OPCODE_B_NOT_NULL = 0xA2 /* alias for BNZ */
};

About

A python script for generating enums with opcode constants based on YAML file definition

Topics

compilerscppemulationgeneratorsopcodeprogramming-language-developmentpythonrustvirtual-machine

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.