CESIL? What on earth is that, I hear you cry! Or maybe some of you are recoiling back in horror at the name of the 1970’s educational programming language stirring up bad memories…
Or you’ve read this months MagPi magazine and seen the article there!
Recent years have seen a resurgence in various activities to resurrect or re-create some of the very first computers that were built. The National Museum of Computing on the Benchley Park estate is home to many projects – and recent additions have been “Colossus” which was designed to break the Lorenz cipher and started working in 1943-1944, and the WITCH computer which came online in 1951 and was recently rebuilt and “rebooted” using most of the original parts in November 2012.
CESIL stands for: Computer Education in Schools Instructional Language. It was a simplified assembly language which students would write out on special coding sheets, then send off to their local computing centre and (hopefully!) get back the results of the run a week later – in time to fix any errors and wait another week…
So fast-forward 40 years or so and lets have some fun with CESIL, a few extensions to the language and a CESIL fairy-light controlled Xmas tree…
|LOAD||Transfer the number into the accumulator|
|STORE||Transfer the accumulator into a named variable|
|JUMP||Jump to the given label|
|JINEG||Jump if the accumulator is negative|
|JIZERO||Jump if the accumulator is zero|
|ADD||Add a value|
|IN||Read a number from the keyboard|
|OUT||Outputs the accumulator as a number|
|Prints a literal string (in “quotes”)|
|LINE||Prints a new line|
|JSR||Jump to a Subroutine|
|RET||Return from Subroutine|
|TREE||Create the tree!|
|ROW||Transfer the accumulator into the Row register|
|COL||Transfer the accumulator into the Column Register|
|COLOUR||Set the fairy light indicated by the Row and Column registers to the colour held in the accumulator|
|WAIT||Pause for the given number of centiseconds – Also causes a display update.|
A CESIL program is essentially three columns of text. The first column (which can be blank) is the label – it’s a placeholder in the program which you can “jump” to from other parts of the program. The middle column is the operator – that’s the instruction to execute, and the final column is the operand – this is data for the instruction to use. This data may be the name of a label if it’s a jump instruction, it may be a number or it may refer to a named memory store, or variable.
The CESIL machine has one register or accumulator. This implementation is limited to a maximum of 256 program lines and 256 variables.
My extensions to the CESIL machine have included 2 more registers to hold the row and column locations of the lamps and a colour instruction to set the lamp colour as well as a subroutine facility.
As an example: here is a simple CESIL program to print out a multiplication table:
# mtable: # Multiplication table generator line print "Multiplication table generator" line print "What table" in store table load 1 store index loop: load index out print " TIMES " load table out print " = " mul index out line load index add 1 store index sub 11 jineg loop halt
But maths is boring… So lets play with the xmas tree instead. Here is a picture of our tree with the bottom row of 8 lights red and the rest silver:
This program makes all the fairy lights silver:
# silver: # Make the tree silver! # Note: We have 4 rows of 8 columns and # Row 0 is the bottom, column 0 is to the left # Fire up the tree tree load 7 # code for silver store colour load 3 # 3 into the Acc loop: store row-count row jsr fill-row load row-count sub 1 jineg done jump loop done: halt # fill-row: # 8 columns in each of the 4 rows fill-row: load 7 fill-loop: store col-count col load colour colour load col-count sub 1 jineg fill-done jump fill-loop fillDone: ret
Get the software
This CESIL interpreter is written in RTB (Return to BASIC), so the first thing you need to do is install the RTB interpreter if you don’t have it already.
Fetch the CESIL code and examples using GIT:
git clone git://git.drogon.net/cesil cd cesil rtb cesil
and off you go. Check the files in the cesil directory – you’ll find several examples including the multiplication table generator (mult), a prime number generator (primes) and a few other examples (all with filename extension .csl) the row-up.csl program contains some handy subroutines for filling the entire tree or one row or one column with a single colour…
You can stop any running CESIL program with the Q key on the keyboard, and pause it with the spacebar.
CESIL programs can be written using any text editor (e.g. nano, vim, etc.) and you can type in upper or lower case – they get translated to upper-case at load time. Filenames should have a .csl extension to them, but you don’t need to type that when loading a CESIL program into the interpreter.
And during December and January 2012, there is a little fun competition running to win one of my Raspberry Ladder boards – but to find out more about that, you’ll need to go and read the MagPi magazine article, or just email me (email@example.com) with your programs by the 25th of January, 2013 and I’ll make the selection by the end of January.