Skip to main content

RASP Machines

last release on PyPI License Build status Code coverage Code quality Downloads

This is a small Python 3 emulator for the random access stored procedure machine (RASP) designed by Cook & Reckhow in 1973 below. I developed this as a companion tool for a course in algorithms & data structures, where it helps (I hope) to with understanding computation models, growth orders and the applicability of the Big-O notation.

  • Cook, Stephen A., and Robert A. Reckhow. "Time bounded random access machines." Journal of Computer and System Sciences 7, no. 4 (1973): 354–375. DOI

In a nutshell, the RASP machine is a mini computer with eight instructions, two registers (an accumulator and instruction pointer), and an I/O device. As a computation model, it closely resembles an actual computer, as opposed to a Turing machine for instance.

How to install RASP?

The simplest way to install the latest version is to use PyPI as follows:

  $ pip install rasp-machine

Please, refer to the documentation for a more comprehensive help!

How to use the RASP machine?

A Simple Program: Adding Two Integers

Let us consider a tiny program for the rasp machine. To simplify writing programs, RASP provides a simple assembly language, as shown below, with the code needed to read two integers from the I/O device and to print their sum back onto it.

segment: data
    left     1       0
    right    1       0
    result   1       0

segment: code
    read     left      ;; left = user_input()
    read     right     ;; right = user_input()
    load     0
    add      left
    add      right
    store    result    ;; result = left + right
    print    result
    halt     -1

Provided we save the code above into a file named addition.asm, we can get the associated machine code, using the following command

$ rasp assemble addition.asm
Machine code saved in 'addition.rx'

Note that the option --debug will yield machine code that contains debugging information, useful when using the debugger.

Debugging & Executing RASP

Now we have the machine code, we can execute it using the following commands:

$ rasp execute addition.rx
rasp? 10
rasp? 20
30

Note that you can extract some performance measure (CPU cycle, read, writes, etc.) using the --use-profiler option.

Should there be any problem with the execution, we can start the associated debugger with the command:

$ rasp debug addition.rx
RASP-Machine 0.1.0
 ┼ debug >

Metadata

Release files for RASP-Machine 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RASP-Machine 0.1.2
File Size Uploaded Provenance Actions
RASP-Machine-0.1.2.tar.gz 18.1 kB Without provenance Details for RASP-Machine-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RASP-Machine 0.1.2
File Interpreter ABI Platform Actions
RASP_Machine-0.1.2-py3-none-any.whl Python 3 none any Details for RASP_Machine-0.1.2-py3-none-any.whl

Total release size: 42.8 kB

Release files / RASP-Machine-0.1.2.tar.gz

Download URL RASP-Machine-0.1.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
869a1a28997ff8104bd17787cbd18cc62f0dbd22a9c4e59ff379b639c33f8061
BLAKE2b-256 checksum
How to use checksums
0ecd80e438805fc9ac78502a31807b351932e8d602e02e077f7a7034f9cd58f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release files / RASP_Machine-0.1.2-py3-none-any.whl

Download URL RASP_Machine-0.1.2-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbcc7290c0236ee1b509dd2c7ccc6314c96e086235621290b0523d6a38e52c11
BLAKE2b-256 checksum
How to use checksums
c8820f0a2b8e61fab9ba156a61416dfa47f95247b9c1883641318bcc75734ecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Security for RASP-Machine 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page