Skip to main content

An emulator for the RSC architecture written in Python.

Project description

pythonRSC ( Relatively Simple Computer in Python )

pythonRSC is an emulator for the RSC architecture written in Python.

With this program, you can generate bytecode from microcode files for Logisim or just emulate microcode files out right. Additionally, you can debug your program and see its every step or even generate a control flow graph of your emulated program.

Installing pythonRSC

To download the package, you can simply use pip.

pip install pythonRSC

Emulating your microcode using pythonRSC

After downloading the package, you should have access to a command called 'pythonRSC'. To use this command, you will need a microcode file to emulate. There are some test files provided.

pythonRSC run microcode.txt

This will parse the given microcode and output the state at the end of emulation.

Generating bytecode using pythonRSC

If you desire to use the in-built assembler to parse the microcode into logisim bytecode, there is a command for that. You will need to provide a microcode input file and it requires an output file to function.

pythonRSC assemble microcode.txt -o output.txt

Emulating and debugging your microcode (timelessly) using pythonRSC

If you want to debug your program, pythonRSC provides an easy-to-use debugger similar to GDB Debugger, but it is timeless! Timeless means you can go forwards and backwards in execution, so this will prevent you having to restart the emulator chasing an issue. To start the emulator with the debugger, use the following command.

pythonRSC debug microcode.txt

After executing, you will be met with a blinking >> awaiting your next command. The list of commands accepted by the debugger are listed below.

stepi [stepsize] This will 'step' forward once if stepsize is not provided, otherwise it will step as many times as provided in stepsize.

backi [stepsize] This will 'step' backwards once if stepsize is not provided, otherwise it will step as many times as provided in stepsize.

bp [addr|label] ... This will set a breakpoint at the given address(es) in hex or decimal or at given label(s). Breakpoints are enabled on initialization.

enable [addr|label] ... This will turn on a breakpoint if it was disabled, it can take a variadic amount of breakpoints to be enabled.

disable [addr|label] ... This will turn off a breakpoint, it can take a variadic amount of breakpoints to be disabled.

disas [start] [end] This will take a range of addresses and disassemble the instructions. Hexadecimal or decimal.

disas This variation of the disassemble command will try to identify if you are inside a label and disassemble that label for you.

print [type] [reg] This will print a register in your desired format (type). The types are /d (decimal) /t (binary) /x (hexadecimal).

run Resumes emulation unless a breakpoint is hit or HALT is met.

info This will print the current state of the emulator, in other words print all registers.

help This will just list the possible commands.

Generating a control flow graph for your microcode

If you wish to generate a control flow graph from your microcode, you simply pass a flag to the CLI.

pythonRSC run microcode.txt -cfg pdf or pythonRSC debug microcode.txt -cfg png

Graphviz is required to be downloaded and on your PATH for this to work properly.

The control flow graph will appear at the end of execution. The graph is rendered using Graphviz and the library pythonCFG.

An example graph:

image

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

pythonRSC-1.2.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

pythonRSC-1.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file pythonRSC-1.2.0.tar.gz.

File metadata

  • Download URL: pythonRSC-1.2.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for pythonRSC-1.2.0.tar.gz
Algorithm Hash digest
SHA256 faec021c09a81eaa837d18040b73e7150c8ce1452e7c565ac00ed3ff4f9ecb60
MD5 1c9a53b894fd9c99bef1d22c6d06a0b4
BLAKE2b-256 6b2279c4842ff87256f95a8a48739fd8358331b7a175ed9d7944381c0ecbd333

See more details on using hashes here.

File details

Details for the file pythonRSC-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pythonRSC-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.0

File hashes

Hashes for pythonRSC-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a439a440de7f0ad7f93cadd7dc1cfb02e9dd619a14ee66a3b696e786df08605
MD5 c82d245e715751a0c1ac564a837335d6
BLAKE2b-256 1e8a3923d8b491d8b336f2edd3072c487c2dfee84b81407f43638a4125a6ed46

See more details on using hashes here.

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