Giter VIP home page Giter VIP logo

algolearn's Introduction

algolearn - a 16-bit "learner computer" in Python

algolearn provides a very simple "learner computer" in Python to solve foundational algorithmic challenges that has historically been taught in Pascal, C or even Basic.

You write programs in Python and have access to a "VM" with 16 bit memory (64k in 64 byte pages). There are only limited instructions available and you need to learn about pointers.

Running

Currently it's all quite simple, you can simply use Python 3.5 from your system without dependencies.

$ python3 l1.py <yourprogram>

There are a number of boilerplate files that you can use to get started:

$ python3 l1.py linkedlist.py

API

Here's the list of available instructions:

  • malloc(size) -> address
  • free(address)
  • write(address, value)
  • read(address) -> value
  • write_addr(address, value_address)
  • read_addr(address)

And the data types:

  • values - are single bytes (8-bit, 0..255)
  • addresses - are words (16-bit, 0..2^16-1)

Additionally you can access a constant:

  • PAGESIZE (could vary, default is 64 bytes)

Notes

  • The zero page is pre-allocated and used for system purposes (really, real machines would have those for ROMs but I just want to not use it to avoid null pointer confusion and I don't want to necessarily have virtual memory (yet))

  • The VM performs a certain amount of accounting and assigns a cost to every operation and reports on it at the end. The specific cost is assigned in a "strategic" way for teaching, not for ultra realistic simulation.

  • I'm pondering to add RestrictedPython to the mix so that specific VMs can limit what the students have access to. However, I do want them to be able to take some convenience shortcuts (accessing print and output formatting) so they can focus on the algorithm. I likely want to reduce access to higher order data types (lists, sets) etc so that I don't have to manually review the code for unintended overreach.

Future

We're using this for our apprentices and if this takes off then I might create multiple VM implementations with different limitations and abilities.

Feedback and contact

I'm happy to get feedback, questions, and ideas. Simply make a Github issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.