Skip to main content

Minimal BASIC interpreter for running MININEC

Project description

Author:

Ralf Schlatterbeck <rsc@runtux.com>

This is a BASIC interpreter for an old dialect of the language used in early IBM PCs – and, in fact even earlier incarnations of BASIC that existed on a UNIVAC (according to [1] the code there – which can be run with Yabasi – ran on a UNIVAC).

It is written in Python. I wrote this over a weekend to be able to run old MININEC code (the linked version of MININEC contains some small fixes). It has almost no error checking (it relies on the code being correct not trying to aid you in writing a new program in BASIC, I think the world does not need new code in BASIC). If you’re looking for a working BASIC interpreter, look at the pcbasic implementation, it is also in Python but faithfully reproduces the memory limitations of the machines at the time. And it seems to use single-precision floating point numbers. This is why I wrote my own interpreter: I needed to compare computations in double precision and I could not fit some examples into the limited memory of pcbasic.

I’m probably not going to put much work into improving this code, it has achieved the purpose: Running (and debugging in Python) old MININEC code to allow me to compare the computations in BASIC to my re-implementation of MININEC in Python, pymininec.

But in fact the code can now run more than the publicly available version of MININEC and implements some of the basic binary file I/O mechanisms of the time.

Changes

Version 1.0: More fixes

This version has a lot of fixes that go beyond just running MININEC, it can now be used to read binary files (MININEC used a pre-processor script to create a binary representation of an antenna geometry) and it can run programs without a line number on every line.

  • We no longer require line numbers on every line

  • Handle multi-line IF/END IF

  • Dynamic DIM statements

  • Binary File I/O with GET/PUT, note that a file is opened for binary if a record length is specified, this probably should change at some time to just convert everything written to a file from python’s string representation where necessary and open all files in binary mode. We use the default in Basic of opening a file read/write, so don’t be surprised if a file opened for reading which doesn’t exist is created with zero length.

  • Conversion of int and float from/to strings – in python the strings are represented as bytes objects – these are the functions MKI$, MKS$ and fixes to CVI and CVS

  • Bug-fix when a GOSUB is not the last statement in a list of statements (e.g. in IF expr THEN list-of-statements), this did not execute the GOSUB previously

Version 0.3: Fix rules for printlist

The syntax of parameters to the PRINT statement can either use a semicolon (or a comma) to separate expressions or just put the expressions together without a separator. The latter had some quite ad-hoc rules and I’ve removed many of them, the result removes a reduce/reduce conflict…

Version 0.2: First working (released) version

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

yabasi-1.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yabasi-1.0-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file yabasi-1.0.tar.gz.

File metadata

  • Download URL: yabasi-1.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for yabasi-1.0.tar.gz
Algorithm Hash digest
SHA256 92158334f9fe3d987eccfc0a793bf974c580b18d5f78b252e32603426ba21afc
MD5 a3c3b34320f31be6dd6824ac624d526b
BLAKE2b-256 4cd9188a856bc74e145b70c40810a5bad834b622fc43572555eeac337a5ac4f2

See more details on using hashes here.

File details

Details for the file yabasi-1.0-py3-none-any.whl.

File metadata

  • Download URL: yabasi-1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for yabasi-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 238413093f3dbc59a9d9c43a50dd8816c0e24af5ea410640e6ab5e41e1d44024
MD5 5312f0427b186a33158815cbd7e99fb6
BLAKE2b-256 5aada379bae2910340518d3d3e9601aebf8d32a6b282acac6c7fdcc60cade669

See more details on using hashes here.

Supported by

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