It’s extraordinary: the release of a new piece of computing technology has generated a huge wave of nostalgia for 30 year old kit such as the Sinclair ZX81, ZX Spectrum and the BBC Micro. The RasPi represents the latest stage in an illustrious line of computing development at Cambridge going back to 1949 and EDSAC built by Maurice Wilkes and his university team. People of a certain age, like myself, have dredged up the old memories and in many cases the actual hardware out of the attic. Well, everybody has heard of the Sinclair Spectrum, but what of the white box in the photo below dwarfing the RasPi amongst the clutter on my desk?
Looking like a Sinclair ZX80, it is yet another Z80 microprocessor based computer, designed by a couple of guys from the Spectrum development team who set up their own company, Jupiter Cantab to build and sell it. Called the Jupiter Ace, it wasn’t really aimed at the beginner because of the computer language it used – Forth. This language caused a lot of excitement in the early 80’s because of its efficiency and was ideal for programming microcomputers. It became popular in real-time control applications, particularly robotics, and is still used today. It is also a semi-compiled language unlike the BASIC of the Spectrum which is fully interpreted.
Forth programs look really incomprehensible because they use Reverse Polish Notation (RPN) instead of the conventional algebraic. Anybody using a Hewlett Packard calculator at the time was familiar with this seemingly odd way of doing things.
Algebraic: C = A + B Reverse Polish: A B +
In fact RPN is the ‘natural’ syntax for computers and explains why Forth is so efficient. The language makes extensive use of the classic push-down memory stack. In the simple example above, A is ‘pushed’ onto the stack followed by B. The + operator ‘pops’ A and B off the stack, adds them and pushes the result back onto the stack. The main problem with this type of programming is keeping a mental image of all the items on the stack at each stage while developing the program.
At that time, 1982, I wrote my own Forth interpreter/compiler for the 8085 microprocessor, developed on a microcomputer running the operating system CP/M, the predecessor to MS DOS. It was used to program a microprocessor-based lab instrument I’d designed. The interpreter section of the Forth environment fitted into a 4 Kbyte EPROM on the instrument’s PCB. I didn’t know it at the time, but I’d built what we now call an ‘embedded’ system programmed in a high-level language.
Here is a fragment of a Forth program that performs a standard piece of digital signal processing. No prizes, but can anybody see what it does?
: MYSTERY 1 DUP M1 ! SFACT ! 256 M2 ! 9 1 DO SCALE
M2 DUP @ 2/ SWAP C! 0 M3 !
M1 @ DUP 2* M1 ! DUP K1 C! 1+
M3 @ DUP C/S @ U2 ! 192 + 255 AND C/S @ U1 !
256 I DO
I K1 @ + L1 !
L1 @ REAL @ DUP U1 @ 32767 */
L1 @ IMAG @ DUP U2 @ 32767 */
ROT SWAP – SWAP U1 @ 32767 */
ROT U2 @ 32767 */ +
DUP I IMAG @ SWAP – L1 @ IMAG ! I IMAG +!
DUP I REAL @ SWAP – L1 @ REAL ! I REAL +! M1 @ +LOOP
M3 @ M2 @ + M3 C!
LOOP LOOP ;
Meanwhile back to Python on the Raspberry Pi.
If you're stuck for something to do, follow my posts on Twitter. I link to interesting new electronics components and development kits (some of them available from my employer!) and retweet posts I spot about robot, space exploration and other issues.Like this Leave a comment