1 unstable release

0.9.0 Oct 7, 2024

#618 in Development tools

Download history 157/week @ 2024-10-04 35/week @ 2024-10-11 3/week @ 2024-10-18

195 downloads per month
Used in 2 crates

GPL-3.0-or-later

80KB
2K SLoC

A simulator, as any computer, it is hardly useful with no programs. Since I didn't know how to program a P101, I started looking at other simulators for P101 sources. I found out that there is no standard format. So, in order to read all such formats I implemented a generic framework leveraging traits and a strongly typed instruction representation.

The Encoding trait defines how to convert a text line in an instruction and vice versa. There are two encodings:

  • the standard one which represent instructions using the original code symbols. Once you master the programming language it is easy to read. On the other hand, writing code is not straightforward because many symbols are not available on modern keyboards; you have to copy paste the exact unicode character.
  • the second one is the AsciiEncoding, which takes the opposite approach and express operations using tokens made of ASCII only characters. Easier to write but less readable in my own opinion. Decoding is not implemented as of now.

On the web I found other encoding loosely based on CSV triples that I may support in the future. For instance https://github.com/Fabioamd87/P101, which is similar to the (retired?) emulator for University of Cassino.

Optionally one can implement the Annotator trait to comment each line during encoding. I find this improve code readability as P101 instruction are largely simbolic and you have to get used to.

Encodings are used by a generic Encoder to convert program into text and a generic Decoder to convert a text into a Program. The LariniDecoder is specialized for the format used by the simulator wrote by Claudio Larini that also has made available most P101 programs.

Dependencies

~2.2–3MB
~54K SLoC