Skip to main content

Interpreter for the Haverford Educational RISC Architecture (HERA) assembly language

Project description

hera-py

Build Status Coverage Status PyPI

An interpreter for the Haverford Educational RISC Architecture (HERA) assembly language.

Installation

You can install hera-py with pip:

$ pip3 install hera-py

Usage

After installation, hera-py can be invoked with the hera command to run a HERA program:

$ hera my-hera-file.hera

You can also preprocess a HERA program without running it, to see how pseudo-instructions and labels are resolved to HERA code:

$ hera preprocess my-hera-file.hera

Comparison with HERA-C

HERA-C is the current HERA interpreter used as Haverford. It is implemented as a shell-script wrapper around a set of C++ macros that expand HERA instructions into C++ code. hera-py aims to improve on HERA-C in the following areas:

  • Ease of use
    • Cross-platform and easy to install
    • Configurable with command-line options
    • Does not create temporary files
    • Can read programs from stdin
    • Command name has six fewer letters than HERA-C-Run
  • Helpful error messages
  • Simple debugging

hera-py also supports several features that HERA-C does not:

  • Multi-precision multiplication
  • Relative branching by a fixed integer value (e.g., BRR(10))
  • Branching by the value of a register (e.g., SET(R1, 20); BR(R1))
  • Setting registers to the value of a label

HERA-C has a few features that hera-py does not:

  • C-style #define macros (and more generally the ability to embed arbitrary C++ code in HERA programs)
  • Relative branching to labels (though the same outcome can be achieved with register-mode branching)

Design

Running a HERA program takes a few steps:

  1. The text of the program is parsed into a list of instruction objects. (hera/parser.py)
  2. The symbol table for the program is generated. (hera/symtab.py)
  3. The program is type-checked to ensure that all operations take the proper number and type of operands. (hera/typechecker.py)
  4. Pseudo-instructions are converted into actual instructions, and labels and constants are substituted for their values. (hera/preprocessor.py)
  5. The instructions are executed on a virtual HERA machine. (hera/vm.py)

For more details about the implementation, see the docstrings in each module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hera-py-0.4.0.tar.gz (37.9 kB view hashes)

Uploaded Source

Built Distribution

hera_py-0.4.0-py3-none-any.whl (60.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page