BASIC’s 50th, early micros, and ACE BASIC for the Amiga

May 4, 2014

I enjoyed reminiscing about BASIC when it recently turned 50, on May 1 2014. I learned more about the events surrounding the creation of Dartmouth BASIC from the Dartmouth web pages and especially from interview videos with co-inventors John Kemeny and Thomas Kurtz. Given my development of ACE BASIC for the Amiga in the mid-90s, the BASIC programming language has a special place in my heart. More about ACE shortly. My first experience with BASIC and programming in general was in 1977, in my second year of high school (Norwood High). Our class marked up a deck of cards (in pencil) with a BASIC program and submitted them to Angle Park Computing Centre. A week or two later I remember receiving a printout of a partial run, showing an ASCII plot of some function (a deceleration curve I think) tantalisingly cut short by an error, the details of which I don’t recall.

At the time I thought that was an interesting experience but set it aside. As I described here, in 1978, the school bought a PDP-11 and installed it in an air-conditioned room complete with a card reader, printer, and terminals. I remember seeing the machine for the first time, gawking in wonder through the glass window in the door to the room. 11_20_console_hirespdp11-software2-r   For the first 6 months most students were only allowed to create card decks rather than using a terminal. At least the turnaround time was less than for Angle Park: you could get your program run’s print-out, correct errors in your card deck and submit it again via the card reader’s hopper.

Apart from a small amount of class-time exposure to the machine, I became a “computer monitor”, assigned on a roster to be there while others used the computer, given a modicum of responsibility for looking after the machine (e.g. card reader or printer problems, booting) but I didn’t learn too much more about the PDP-11 that way.

What really hooked me, was eventually being allowed to use the terminals (pictured at right) and the interactive BASIC programming that entailed. There was plenty of competition for terminal time! One of the first interactive programs I wrote was a simple guess-the-number game in which the user was told whether a guess was less or greater than the number the machine was “thinking” of. It seems trivial now but that experience of interacting with an “artificial intelligence” (as it seemed to me at the time) was intoxicating and this has stayed with me. Some fellow students started playing around with machine language on the PDP-11; that was a little beyond me at the time but an understanding of that level would become important for me later.

In the late ’70s, Tandy had a computer store in Gawler Place, Adelaide. I used to catch a bus into town on Friday nights, pull up a chair at a TRS-80 Model 1 on display and sit there for an hour or two typing in BASIC source code for games from a book; the sales people didn’t seem to mind too much. :)

When I’d finished year 12 of high school, had started working as a nurse in 1981, and was earning money, I bought a CASIO FX-702P, essentially a calculator with an interface for a cassette recorder (for programs and data and printer that was programmable in BASIC. frontcvr220px-CW-E-frontWithin a year or so, I had a Sinclair ZX-81 connected to my parents’ old HMV black and white TV in the country (where I visited most weekends): a big screen indeed! This odd little machine fired my imagination via its space-age programming manual cover. Adding the 16K RAM expansion pack (shown below at rear) allowed much larger programs to be written compared to the unexpanded 1K machine. ZX81 Programming in BASIC while listening to music like Kraftwerk’s Computer World, with simplistic, German-accented lyrics like these:

I program my home computer. Beam myself into the future.

it somehow seemed that the future was coming fast and that it was going to be overwhelmingly positive. This was a time of innocent joy when nothing was standardised (hardware or operating systems), the term micro-computer was more likely to be used than personal computer, the sterile DOS-based IBM PC “business computer” was barely beginning to emerge and the Macintosh was not yet in sight.

The pages of magazines like Australian Personal Computer and Compute! were filled with BASIC program listings for specific machines just crying out to be adapted to other BASIC dialects. Reading books such as Christopher Evans’ The Mighty Micro (1979) filled me with optimism for the future. Reading Isaac Asimov’s I, Robot and the like fired my imagination, as did TV shows like Dr Who and Blake’s 7. To be honest, all of this was also somewhat of a welcome escape from the daily realities of being a young nurse.

My next machine was a Commodore PET (CBM 4016). Built like a Sherman tank, I added a 5.25″ floppy disk drive (that had cooling problems!) and a dot matrix printer via the PET’s IEEE interface. I happily spent many weekends creating games in BASIC on this computer. I also wrote a version of Eliza-the-psychotherapist that kindled an interest in artificial intelligence and language processing. Occasionally entering the PET’s machine language monitor programming got me thinking more about low-level concepts (processor registers etc). Reading a book called Programming the 6502 by Rodnay Zaks (1981) helped further my understanding. OLYMPUS DIGITAL CAMERA That PET was followed by a VIC-20 and C-64 into the mid-80s both of which I (of course) programmed in BASIC and a bit of hand-assembled 6502/6510 machine code POKEd into obscure areas of memory (such as the cassette buffer, not in use when a 5.25″ floppy disk drive was the secondary storage device). I started to gain some exposure to databases (SuperBase 64), word processors and other programming languages like Pascal. Interfacing with relay boards and sensors was also something I enjoyed using BASIC for with these machines, achieved by POKEing values into and PEEKing values from I/O memory locations. vic20C64_startup_animiert In 1987, after a couple of years going off in various directions, I moved from Adelaide to Tasmania to work as a nurse (in ICU, Recovery etc) where I met my future wife, Karen. I didn’t have any computer with me there because I initially thought I’d only stay for a year or so but ended up staying for a decade. My first computer purchase in Tasmania was an Acorn Electron, little brother to the BBC Micro and programmable in a BBC dialect of BASIC. I also learned a bit of LISP (from a cassette-loaded interpreter) using the Electron. Acorn_Electron_4x3 Commodore_Amiga_500Plus20110501_uae4all_(30-09-2011)_(amiga_500_emu_for_pandora)

By far the most important computer purchase ever for me was a Commodore Amiga 500. I learned so much from that machine, initially programming it in AmigaBASIC and smatterings of machine code, then in C and a handful of other languages. The Amiga’s pre-emptive multi-tasking operating system and state of the art graphics and sound capabilities were fantastic. It was also to this machine that I connected my first hard disk drive. I wrote simple astronomy programs, a simple drawing program for Karen, and created an alarm and security system with infra-red sensors, keypad, strobe light etc. It even woke me (or more likely Karen so she could come to my aid) up if I went for a sleep walk. :) I also used the Amiga and C64 for the pre-Internet Viatel (Australia’s Teletex system), bulletin boards, and Compuserve.

I took a statistics course at UniTas (Launceston) for fun in 1987 and a year or so later had started an Applied Computing degree there. I took a double major in computer science and philosophy. This ultimately lead me away from a career in nursing and onto a software engineering career (after stints as a computer systems officer and a junior academic post-graduation). One of the subjects I took as an undergraduate was “Advanced Programming” in which we wrote a compiler for a subset of Pascal into p-codes (similar to UCSD p-codes and not unlike Java VM bytecodes) rather than assembly or machine code for the native machine (Intel). One outcome is that I became increasingly interested in programming language translation and programming paradigms (especially object oriented, functional, logic and concurrent). Another outcome is that I resolved to take that knowledge and write a compiler for the Amiga for a language that I myself would want to use, not just as an academic exercise.

In October 1991, I started development of ACE BASIC for the Commodore Amiga computer. It was released to testers in March 1992 and made available for public consumption in February 1993. Like the original Dartmouth BASIC, ACE was compiled, unlike many implementations that have been interpreters. ACE was a compiler for the interpreted Microsoft AmigaBASIC that shipped with the Amiga.

This article written for the online Amiga Addicts journal gives some idea of the history and motivations for ACE and here is an interview I gave in 1997 about ACE. Although the instruction set of the Amiga’s 68000 processor was not quite as orthogonal as the PDP-11’s, it was still really nice. ACE compiled BASIC source into peephole optimised 68000 assembly code.

KL_Thomson_TS68000

 

This was assembled to machine code by Charlie Gibbs’ A68K assembler and linked against library code with the Software Distillery’s Blink linker (later I also used PhxAsm and PhxLnk). I wrote 75% of ACE’s runtime libraries in 68000AssemblyLanguageProgramming_2ndEdition68000, later waking up to the idea that C would have been a more productive choice. One upside is that I became quite comfortable working with assembly language. I’ve made use of that comfort in recent years when working with hardware simulator testing (ARM, PowerPC etc) and micro-controller compilers.

A wonderful community of enthusiastic users built up around ACE. I wrote an integrated development environment, and a community member wrote one too (Herbert Breuer’s ACE IDE is shown below).

Another member wrote a “super-optimiser” that rewrote parts of ACE’s generated assembly code to be even faster than I managed with my simple optimisations.

aide HB

ACE was guilty of a criticism by the Dartmouth BASIC co-inventors (John Kemeny and Tom Kurtz) kemeny_and_kurtz_250pxlevelled at many BASICs since their first: of being machine-specific. But then that was the intent for ACE: to make programming the Amiga more approachable to more people, combining the simple abstractions of BASIC with the unique features of the Amiga and the run-time efficiency of a compiled language like C.

Given the Amiga’s demise, around 1996 I moved onto other platforms. I wrote a LISP interpreter for the Newton PDA (also doomed; I can pick ‘em!) between 1998 and 2000. That was fun and had a nice small community associated with it, but it didn’t match ACE and its community.

I eventually came to possess PCs, programming them with a smattering of GW-BASIC, quite a lot of Turbo Pascal, some Microsoft Quick C, a little assembly, and Visual BASIC.

When Java appeared in 1996 I greeted it with enthusiasm and have been an advocate of it and the Java Virtual Machine, as a professional and spare-time software developer, on and off ever since. These days I’m more likely to code in Java, C/C++, Python (where once I would have used Perl) or perhaps R rather than a BASIC dialect, none of which denigrates BASIC.

The fact is that BASIC made early microcomputers accessible such that many of us interacted with them in ways more directly than is possible with modern computers (PCs and Macs), despite all their advantages and power. Arguably, we expected less from the machines yet engaged in highly creative relationships with them. Anyone who has spent much time programming will recognise the allure. The interactive nature of these early BASIC machines only added to this.

I agree with the famous Dutch computer scientist Edsger Dijkstra when he says that:

Computing Science is no more about computers than astronomy is about telescopes.

dijkstra

I also sympathise with his declaration that the BASIC statement GOTO could be considered harmful, due to the “spaghetti code” it leads to. But I don’t really agree with his assessment that:

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

I heard the same propaganda from a University lecturer. Apparently some us of were able to be “rehabilitated”.  Then again, along with his comments about BASIC, Dijkstra made some unkind comments about other programming languages, including COBOL, Fortran, and APL, for example:

The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense.

With apologies to Grace Murray Hopper, I have more sympathy with this last one. :)

archives_hopper

The truth is that all programming languages are crude approximations of the Platonic ideal of bringing together two minds: one artificial, one natural. There are no programming languages about which I can say: there are no improvements possible here, and there are very few languages that make communion with the machine a beautiful experience. All are to be reviled and admired for different qualities. But BASIC, in all its dialects, with all its flaws, and with the benefit of 20/20 hindsight and large gobs of nostalgia, was mostly to be admired and was directly responsible for many of us falling in love with the idea and activity of programming.

programming_languages_tower_of_babel_poster-red3cfd7db90b4be9ab4a803dee3a65b3_wxb_8byvr_512

Viva la BASIC! Happy 50th anniversary!

First V1369 Cen estimate for several days

February 16, 2014

It’s been cloudy here for several days and before tonight, my last estimate of V1369 Centauri was on Feb 10 at magnitude 6.2.

V1369CenFeb162014

My latest visual estimate tonight (under the cross-hairs above) was magnitude 6.55, with 6.5 and 6.6 comparison stars.

V1369 Cen light curve update

February 10, 2014

Here’s an updated light curve for the nova:

V1369Cen11Feb2014

My visual estimates are in purple (click the image to enlarge it) and the cross-hairs are over my latest observation. The polynomial fit (degree 30) highlights the overall shape of the light curve. Only visual and Johnson V observations are shown.

An Arduino Olympic Torch model

February 5, 2014

The 2012 London Olympic Games coincided with my son’s last year of primary school. Each year the school has an “expo” in which students explore and create displays on some theme. In that year the school decided the theme would be the Olympics.

One idea we (my son, wife and I) came up with was a model of an olympic torch with a “flickering flame” effect. This was just one of a number of items that had to be prepared by my son for the “expo”, and some parental assistance was expected, so we helped with that.

My wife created the body of the torch from a cone-shaped industrial cotton reel and  cardboard coffee cup, all spray-painted gold.

I considered using a PIC micro-controller and a couple of discrete tri-colour high-intensity LEDs, but given the time and size constraints I decided to use a Freetronics LeoStick Arduino with two high-intensity LED units on a ProtoStick (from Jaycar in Adelaide) powered by a 9V battery. The LeoStick sits inside the coffee cup with cellophane over the top to provide a diffuser (added by my wife), as shown below.

ArduinoOlympicTorchTopView-cropped

A momentary push-button switch is used to start the “flickering flame” for a short time as shown in this YouTube video.

The serially clocked tri-colour high intensity LED units randomly and rapidly cycle through various colours to produce the effect.

This Freetronics page describes the LED components and their usage in more detail.

The following image shows the individual disassembled components:

ArduinoOlympicTorchComponents-cropped

Note the large (by comparison to the LeoStick) home-brew 5V regulated power supply to which a 9V battery is connected. The power supply and battery sit inside the conical handle attached to a toggle switch (power on/off) in the base, a water bottle lid in this case.

The following image shows the components connected:

ArduinoOlympicTorchCompleteCircuit-cropped

The high-intensity LED units are attached to the ProtoStick via headers soldered to the latter.

The following schematic shows the simple Arduino-based circuit:

arduino-olympic-torch-schematic

The resistor in the schematic is a surface mount component soldered to the ProtoStick.

The code for the project is shown below. As can be seen from the excluded code at the end of the loop() function, I toyed with adding a wake-from-sleep interrupt to conserve power while the circuit was active, but didn’t get that to function within the time available. There was no loss of functionality of course, just a greater drain on the battery because of the unfortunate busy-looping.

/*
  * 2012 EMPS Expo Olympic Torch RGB LEDs, for Nicholas.
  *
  * Arduino (LeoStick)
  *
  * References:
  * - http://www.freetronics.com/pages/leostick-getting-started-guide#.UBOpjJkthmo
  * - http://www.freetronics.com/pages/rgbled-rgb-led-quickstart-guide#.UAq-qZktg38
  * - http://www.arduino.cc/en/Tutorial/Debounce
  *
  * dbenn@computer.org, August 2012
  */

 #include <avr/sleep.h>

 // RGB LED strip pins (clock and serial data).
 const int CKI = 10;
 const int SDI = 12;

 // Button pin
 const int BUTTON = 2;

 // Button state variables.
 int buttonState = LOW;
 int lastButtonState = LOW; 

 // The following variables are longs because the time, measured in miliseconds,
 // will quickly become a bigger number than can be stored in an int.
 long lastDebounceTime = 0;  // the last time the output pin was toggled
 const long DEBOUNCE_DELAY = 50;  // the debounce time; increase if output is unstable

 // Function prototypes.
 void wakeupHandler();
 void blankLEDStrip();
 void randomiseLEDStrip(long millisecs);
 void setLEDStrip(int color1, int color2);
 void pushLED(int color);
 boolean isButtonToggled();
 boolean isButtonPressed();
 long getRndColor();

 void setup() {
   pinMode(BUTTON, INPUT);
   pinMode(SDI, OUTPUT);
   pinMode(CKI, OUTPUT);
   randomSeed(analogRead(1));
   blankLEDStrip();
 }

 void loop() {
   // When the button is toggled, generate
   // random colors with random pauses between
   // each for 15 seconds, then blank the LED strip.
   if (isButtonToggled()) {
     randomiseLEDStrip(15000);
     blankLEDStrip();
   }
 #if 0
   // A sleep mode with wake-from-interrupt would decrease power consumption.
   set_sleep_mode(SLEEP_MODE_PWR_DOWN);
   sleep_enable();
   interrupts();
   attachInterrupt(0, wakeupHandler, RISING);
   sleep_mode();
 #endif
 }
 #if 0
 void wakeupHandler() {
   // When the button is toggled, generate
   // random colors with random pauses between
   // each for 15 seconds, then blank the LED strip.
 //  while (!isButtonToggled());
   randomiseLEDStrip(15000);
   blankLEDStrip();
 }
 #endif
 // Blank the RGB LED strip.
 void blankLEDStrip() {
     setLEDStrip(0x00000000, 0x00000000);
 }

 // Generate random colors for random periods for specified number of seconds.
 void randomiseLEDStrip(long millisecs) {
   long t1 = millis();

   while (millis() <= t1+millisecs) {
     setLEDStrip(getRndColor(), getRndColor());
     delay(random(100));    
   }
 }

 // Set the colors on the RGB LED strip.
 void setLEDStrip(int color1, int color2)
 {
   pushLED(color1);
   pushLED(color2);

   // Pull clock low to put LED strip into reset/post mode
   // and wait for 500 microseconds for completion.
   digitalWrite(CKI, LOW);
   delayMicroseconds(500);
 }

 // Push a 24-bit RGB colour data (RRGGBB; red is MSB) out to the LED strip.
 void pushLED(int color) {
   for (int color_bit = 23 ; color_bit >= 0 ; color_bit--) {

     // Low clock signals bit change start.
     digitalWrite(CKI, LOW);

     // Force mask to be 32-bit instead of 16-but by default.
     long mask = 1L << color_bit;

     // Write data bit and latch.
     digitalWrite(SDI, color & mask ? HIGH : LOW);
     digitalWrite(CKI, HIGH);
   }
 }

 // Returns whether the button was toggled (pressed then released).
 boolean isButtonToggled() {
   boolean toggled = false;

   if (isButtonPressed()) {
     while (isButtonPressed());
     toggled = true;
   }

   return toggled;
 }

 // Returns whether the button was pressed since the last time the function was called.
 boolean isButtonPressed() {
   // Read the state of the switch into a local variable.
   int currentButtonState = digitalRead(BUTTON);

   // Check to see if we just pressed the button 
   // (i.e. the input went from LOW to HIGH), and we've waited 
   // long enough since the last press to ignore any noise.  

   // If the switch changed, due to noise or pressing...
   if (currentButtonState != lastButtonState) {
     // ...reset the debouncing timer.
     lastDebounceTime = millis();
   } 

   if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
     // Whatever the current button state is, it's been there for longer
     // than the debounce delay, so take it to be the actual current state.
     buttonState = currentButtonState;
   }

   // Save the current button state. Next time through the loop,
   // it'll be the lastButtonState.
   lastButtonState = currentButtonState;

   return buttonState == HIGH;
 }

 // Return a random color.
 // Proportions of each color component can be tweaked in the selection comparisons.
 long getRndColor() {
   long primary = random(100);
   long rgb = 0xFFFFFF;

   if (primary < 50) {
       rgb = 0xFF0000 | random(0x100) << 8 | random(0x100); 
   } else if (primary < 75) {
       rgb = 0x00FF00 | random(0x100) << 16 | random(0x100); 
   } else {
       rgb = 0x0000FF | random(0x100) << 16 | random(0x100) << 8; 
   }

   return rgb;
 }

V1369 Centauri Light Curve update

February 4, 2014

My latest visual estimate of the nova is magnitude 6.0 (with comparison stars 6.0 and 6.1). Here’s the latest V and visual light curve.

V1369CenFeb52013

The overall fading trend continues with some oscillations. The latest VSS newsletter has some interesting articles about the nova.

V1369 Cen update

January 27, 2014

The nova is gradually on the way down, but it’s certainly not smooth. Here’s the latest light curve.

V1369CenJan272013

The cross-hair is on my latest visual estimate (5.85). Rob Jenkins (a fellow ASSA member) made a photometric observation (5.932, Johnson V) a couple of hours later. Subsequent visual estimates suggest the nova has brightened a little again.

V1369 Cen light curve update

January 19, 2014

The overall decline continues with intermediate rises and falls. Tonight I estimated the nova at magnitude, 5.5 bracketed by 5.4 and 5.6 comparison stars.

V1369CenJan192013

The polynomial fit (in red) shows the essential shape of the light curve and overall downward trend.

V1369 Cen faded since Jan 8, rising again

January 12, 2014

I was away for 3 days but tonight have estimated V1369 Cen at magnitude 4.9, compared to 4.5 on January 8th.

V1369CenJan122013

Despite an apparent rise again now, the “sawtooth” pattern of peaks appears to be showing an overall downward trend. I wonder whether that will that continue.

Another peak for V1369 Cen

January 8, 2014

I just came inside after making another visual estimate of V1369 Centauri. The roller-coaster of the nova continues as shown by the updated light curve.

V1369CenJan92013

 Click on the image to enlarge it. My several observations are in purple as usual.

The nova in Centaurus from Stockport

January 5, 2014

I spent last night at a really well-attended ASSA member’s night at Stockport Observatory last night, an awesome start for 2014.

A number of members enjoyed views of the nova in Centaurus (V1369 Cen). The cross hairs in the light curve below are over my visual estimate just after 1am; as in previous posts, the observations in purple show others I’ve made (only 5 up to this point).

V1369CenJan52013

The details of the observation are as follows:

V1369 Cen Obs Details Jan 5

When I first submitted the observation to AAVSO at around 3am, it was around 0.3 magnitudes brighter than the previous one. Others have since submitted more observations around the same time with similar magnitude values.

The nova was clearly visible to the unaided eye from Stockport at that time, as were the 4.7 and 4.3 comparison stars I used for the estimate (shown, by the conventional labels, as 43 and 47 above).

An observation a couple hours earlier at around 10:30pm when the nova was closer to the horizon was around 4.8 but I was a little uncertain of the estimate due to the low altitude so I didn’t submit that one to AAVSO.

Will the current rise continue past the last peak? The only way to find out is to keep watching!

I also made visual estimates of the Classical Cepheid l Carinae and LBV (Luminous Blue Variable) η Carinae. I had aimed to make estimates of others (R Carinae and V Puppis) but didn’t quite get there. I was too busy having a good time looking at other objects through my Meade LX-90 ‘scope and sharing views with ASSA members.


Follow

Get every new post delivered to your Inbox.