Celebrating 50 years of BASIC: My first “production” code in BASIC.

In the late 70s/early 80s there was a sudden rash of 8-bit microcomputers on the consumer market. They were all based on either the Zilog Z80 or the MOST 6502 microprocessors. I made a mistake – I bought the Commodore VIC20 which said it had 8k of RAM. I didn’t realise that 3K of that would be loaded with BASIC from ROM at startup leaving only 5k to program with. But I liked the “real” keyboard… Most of my mates went for the Sinclair Spectrum – crappy keyboard but higher-spec (well aside from the limitations of the Z80), more RAM.

The VIC 20, with a real keyboard.

The Spectrum with its dreadful rubber keyboard. Note each key has its own BASIC keyword. Awful!

I messed around with it a lot. I was particularly interested in writing code directly for the 6502 processor but even to get machine-code loaded you had to write a BASIC program and so I became vaguely interested in BASIC.

In the early 80s I entered aircrew training with the Royal Air Force. This was immediately after the Falklands war and there was a huge resurgent interest in Morse Code. This is because with all the Electonic Countermeasures, the only communication that worked effectively during the conflict were the dahs and dits (not dots and dashes – saying that shows you’ve never sent/received morse code) as human operators listened in and could detect tiny differences of tone in amongst all the radio-frequency jamming. They could just about make out a dah from a dit and they could therefore receive messages despite the hostile RF environment.


Searching for submarines on board a Nimrod

I got chopped off the course after just over 12 months because of a security incident and returned to previous duties looking after airborne communications, radar and flight systems. One of the reasons cited for my being chopped was my weakness at receiving Morse code (aside from the security incident that is!).

I immediately re-applied and thought I didn’t want to give them the excuse of Morse code to refuse me. So I wrote a Morse Code program in Commodore BASIC on my VIC20 and I sat there for hours and hours receiving apparently random sets of characters through my headphones.


Line numbered BASIC with GOSUB and RETURN. I varied the speed at which the characters were sent and slowly built that up until I could receive at about 30 words per minute. But I did notice a problem. I’d think to myself “I recognise this pattern”. Eventually, I discovered the entire series of random characters were part of a very large circular pattern – thousands of characters long, but a pattern nonetheless. So I had to introduce extra random elements to spoil the pattern. All that did was increase the size of the pattern.

This was my first use of BASIC that was of professional value to somebody (me) so I’d say it was my first piece “production” code.

It wasn’t until some years later that I learned about random number generators and how un-random most of them are. It turns out to be very difficult to create random numbers. Imagine if you found a pattern for the pair of primes that are generated for the public key in SSL?

In the end I got fed up with waiting for a decision on whether they’d let somebody with a “security incident” (no I didn’t sell secrets to the enemy!) re-apply for aircrew training, so I left the RAF and joined the computer industry to work on VAX/VMS with DEC. I didn’t touch BASIC again until 1993 when I became massively impressed with how quickly you could knock out a full Microsoft Windows app using Visual Basic v1. It came on 3 floppy disks. After my first experience with it I became convinced Windows would have a great future and I immediately started looking for a job. I eventually got one and that was over 20 years ago…

I haven’t touched Morse in the intervening 30-odd years but I can still remember most of the characters. I’m currently not sure of:

G, J, Q, U, V, W. G, U and W are similar and I get them mixed up.

Interesting facts:

The theme music for Inspector Morse – those notes at the beginning? They spell “Morse” in Morse code.

Nokia: Some people think the SMS ringtone is “SOS”. It’s not, it’s “SMS”. dih dih dih  /  da da  /  dih dih dit.

Nokia: That really long “New SMS” message in morse code says “Connecting”.

dah dih dah dit  /  dah dah dah / dah dit  / dah dit / dit / dah dih dah dit / dah /  dih dit  / dah dit / dah dah dit.   (…and I just realised I remembered G…)…

Planky == @plankytronixx

Comments (4)

  1. Joe Brinkman says:

    I also started my coding career on a VIC-20.  What a great introduction to computing.  Personal computers at the time were simple enough that an individual could realistically learn everything inside and out on how computers worked and how to program them.  I miss those days.

  2. .dan.g. says:

    Hi Planky

    You mention that the correct soundings for 'dots' and 'dashes' are in fact 'dahs' and 'dits', and then you introduce 'dih' as well in the 'Interesting facts' section.

    Is this a mistake or a subtlety in the soundings?


  3. plankytronixx says:

    Good point Dan. Yes, in reality there is dah, dih and dit. You use "dit" to sort of punctuate the end of a character. So "S" becomes dih dih dit. Rather than dih dih dih. If you listen to somebody transmitting on a morse key, it tends to have that consonant sound at the end of the character.

    Also, take the morse code that everybody knows – SOS. That should be sent as a character in its own right, not 3 characters. So rather than dih dih dit – dah dah dah – dih dih dit. It should be transmitted as dih dih dih dah dah dah dih dih dit.

    …see the way the dit is the very last sound? signifying the end of that "character" (even though it was in fact 3 characters really)…

    Just like in the English language there are a bunch of anomalies. For example if you make a mistake and you want to start that word again, you transmit a string of dits. I think there is an official <backspace> "morse character", but if you listen in, you'll find most operators just transmit a string of about 6-8 dits. And they are dits not dihs. Each dit is expressly punctuated. Have a listen to some characters being transmitted (incredibly slowly in this case) and you'll hear a definite "dit" punctuation at the end of any strings of "dih" characters… http://www.qsl.net/…/AtoZvoice.wav .

    If you listen in to a real morse transmission it'll be much faster than that – maybe as much as 40 or 50 words/minute. Receiving at that speed requires a lot of experience (or a computer!)…

    Once you get above about 15 words/minute then the character you are writing down is the one before the character you are currently listening to. I'd think they may well be 4 or 5 characters behind up at 50 words/minute.

    At this site you can put in a message and specify how many words per minute to transmit at. Try it and see if you can even recognise 2 characters from your message. And that's only 30 wpm… morsecode.scphillips.com/jtranslator.html

    Have fun…

    Planky == @plankytronixx

  4. plankytronixx says:

    I agree Joe. Of all those 8-bit computers on the market, they all had BASIC as the default option. And if you wanted to get down to the bare metal you wrote the code out on a piece of paper, translated all those machine instructions in to hex-values and then painstakingly "POKED" those values in to an area of memory you could set up for your program. Then POKED the start address in to the PC (Program COunter) and your program ran – well, more often than not crashed or failed in some way. Debugging was murderous. Inserting a couple of instructions inside a loop was heart-breaking – especially on the Z80 chip because it only had relative addressing (at least the 6502 had absolute addressing for conditional instructions) so all the addresses after the instructions had to be shifted up a bit. And all done on a piece of paper!