Sunday, February 26, 2023

Letters from India Book Project


This post is a little different - it is not about vintage radios, test equipment, or retrocomputing. Rather, it is about a book project I recently completed.


I was part of a middle-class Canadian family of five living in the greater Toronto area of Ontario, Canada. Both my parents were teachers. Around 1969 my father had the opportunity to take a job in India, and the entire family ended up moving and living there for two years from 1970 to 1972.


The sixties had just ended and it was a time of rapid social change, interest in other cultures, and a desire to improve the world. Canada had developed a nuclear power technology that it was exporting to other countries. An agreement was reached with the Indian government to have Canada assist in constructing nuclear power generating plants in India, providing much-needed electrical power to developing areas of the country.

Building nuclear power stations is a long and complex process and you can imagine the additional challenges of replicating Canadian-designed generating stations in India. The goal of the Rajasthan Atomic Power Project was to build several reactors in the north-western Indian state of Rajasthan, near the city of Kota, adjacent to the village (now a city) of Rawatbhata.




To assist in construction of the facility, Canada sent several dozen Canadian engineers and technicians to live and work on the site. This involved building a small community with suitable homes, recreation facilities, and a school for the Canadian families. My father was hired as the head teacher (one of two full-time teachers) for the school for the Canadian children.


We spent two years living there, during which time we did considerable travelling in our Volkswagen camping van as well as by train, airplane, ship, horseback, and motorcycle. 

We visited over a dozen cities ranging from the highly populated Bombay (now Mumbai), the capital of Delhi, to remote parts of Kashmir in the Himalayan mountains.

India was still quite a remote and exotic location for westerners and our only communication with relatives back in Canada was by postal mail. My parents sent regular letters back home reporting on our experiences and adventures. We even sent back photographs, colour slides, and 8mm movie films.



My relatives faithfully keep all of the letters that we sent and recently returned them to us. Fifty years later, the typed and handwritten letters on thin airmail paper are still in surprising good condition.


A lot of effort went into writing these regular newsletters, and I realized that these stories might be of interest to more than just my children and grandchildren. So I undertook a project to enter all of the letters in book form. I added additional background material on my family and the power project, pictures taken at the time, and a postscript of our lives after returning to Canada. The result is a book about 180 pages in length.



The book, Letters From India: The Chronicles of a Canadian Family Living in India from 1970 to 1972, is available directly from lulu.com for slightly under $20 US or the equivalent in other currency.

It can also be found on AmazonBarnes and Noble, Ingram, and other distributors. It uses a print-on-demand service which prints and ships the book locally in many countries around the world.

This book was done as a labour of love for friends and family, but I hope others will find it interesting as well. It provides a unique glimpse into a time when few North Americans were living in or travelling around India.

Wednesday, November 24, 2021

Retrocomputing Basic Implementations

Here is a summary of a number of Basic implementations that I have come across and worked with as part of my retrocomputing hobby. Many of these were ported by me or others to different platforms from the ones they were originally written for (for example, single board computers based on the 6502, 6809, Z80, and 68000 microprocessors). These are all found on my github  account.

Name Developer Platform Code size Comments
Enhanced Basic (68000) Lee Davison 68000 14K Full-featured Basic for 68K platform
Tiny Basic for the 68000 Gordon Brandly 68000 4K Derived from and similar to Palo Alto Tiny Basic.
Enhanced Basic (6502) Lee Davison 6502 11K Full-featured Basic for 6502 platform.
Microsoft Basic for 6502 Microsoft Apple 2, Commodore, KIM-1, OSI, and others 8K Basic used on several early 6502-based microcomputers.
Tiny Basic for 6502 Tom Pitman 6502 3K Originally published in Dr. Dobbs Journal.
Apple 1 Basic Steve Wozniak 6502 (Apple 1) 4K Basic for the Apple 1, later expanded into Apple 2 Integer Basic.
BBC Basic 2 for Acorn Atom/BBC Computer Roger Wilson (Acorn Computer) 6502-based Acorn Atom and BBC Computers 16K Basic for the Acorn Atom and BBC Computers.
Tiny Basic for 6800 Tom Pitman 6800 2K My version runs on the Heathkit ETA-3400.
Tiny Basic for 6809 Tom Pitman 6809 2K 6809 port of 6800 version.
TSC Micro BASIC PLUS Technical Systems Consultants 6809 4K Similar to Tiny Basic.
Sinclair ZX81 Basic John Grant and Steve Vickers, Nine Tiles Networks and Sinclair Research Sinclair ZX80/ZX81, Timex 1000 8K Basic for the Sinclair ZX81 computer.

A List of Cross-Assemblers for Retrocomputing

 In my retrocomputing projects with various processors I have used a number of cross-assemblers to build code. I've had to use several in order to support different processors as well as for compatibility with different software packages. For the most part they are similar, but have their own unique features and quirks.

I put this table together, mostly for my own reference, that others may also find useful. It is by no means a complete list -- just those that I have used.

Name Author Source Supported Processors Key Features Comments
as9 Motorola, with changes by Albert van der Horst and others https://home.hccnet.nl/a.w.m.van.der.horst/m6809.html 6809 macros 100% compatible with Motorola assembler
asl Alfred Arnold and others http://john.ccac.rwth-aachen.de:8000/as/ many (over 50) Macros I have used with several processors
asm6809 Ciaran Anscomb https://www.6809.org.uk/asm6809/ 6809, 6309 macros Good choice if 6309 support needed.
cc65 John R. Dunning, Ullrich von Bassewitz, and others https://www.cc65.org/ 6502, 65C02 C compiler, assembler, linker, librarian Supports several 8-bit computer platforms.
crasm Leon Bottou https://github.com/colinbourassa/crasm 6800, 6801, 6803, 6502, 65C02, Z80 macros Included in most Linux distributions.
gcc Richard Stallman and others https://gcc.gnu.org/git/ Many Compilers and assemblers I used for 68000. Included in most Linux distributions.
lwasm William Astle and others http://lwtools.projects.l-w.ca/ 6809, 6309 Cross-assembler and linker. macros
vasmm68k_mot Volker Barthelmann http://sun.hasenbraten.de/vasm/ Many Cross-assembler I used for 68000.
z80asm Bas Wijnen http://savannah.nongnu.org/projects/z80asm Z80 Z80 cross-assembler Included in most Linux distributions.

Thursday, February 20, 2020

Hugo Winner Book Review: The Snow Queen by Joan D. Vinge



I found this novel rough going. I wanted to give up on it a few times, and I did set it aside for several weeks. But about half way through my interest picked up.

There is nothing wrong with the story or writing. For some reason the plot and characters did not particularly appeal to me and it is leans more towards "soft" science fiction where I am generally a fan of the "hard" genre.

It is very imaginative, and has some very poetic writing.

Tuesday, November 19, 2019

A 68000 Disassembler


I have found that a good way to really understand a microprocessor's instruction set is to write a disassembler for it. I have done this for a number of processors including the 6502, 6800, 6809, and Z80. My udis disassembler was implemented on Python and supports a number of processors.

Having recently worked on my 68000 single-board computer, I decided to write a disassembler for the Motorola 68000. This is more challenging than for 8-bit processors due to it's complex instruction set and many addressing modes. I decided to again use Python as it is fast to develop, readable, and cross-platform.

I wanted the design to be at least partially table based. I started with the table on the Motorola MC68000 Programmers Reference Card, but it did not adapt will to a software-based table. I found a very nice and succinct table  written by someone in France under the name of GoldenCrystal that was a better fit. It organized all of the 68000 instructions and decoding of fields in a logical manner. I made a spreadsheet based on the table data.

The 68000 uses 16-bit opcodes, but they are not unique. Various bits in the opcode control the addressing modes and operands, so I needed to use an approach where each instruction has a bit pattern and a mask indicating which bits to examine when looking for a match to a specific opcode. For example, a NOP is $4E71 and all bits are valid but a MOVE instruction has thw two most significant bits as zeroes but the rest vary with the address mode.

I exported the spreadsheet into CSV format, which can easily be read into a data structure from Python. I then use this data for determining what instruction is read. Then I handle the encoding of the instruction and any extension words or operands. Many instructions follow similar encoding and can use the same logic, while others are unique.

It was somewhat tedious and time consuming to work my way through all of the possible instructions. As I proceeded, I wrote a test program with the instructions I was implementing and examples of each addressing mode. An additional good "stress test" of the code is to use random data (such as /dev/urandom on Linux) as input and make sure that it does not crash or produce errors.

After few weeks of occasional evenings (interrupted by a trip to Europe) I had finished support for all instructions. The most complex was the MOVE instruction as it supports almost every addressing mode for both source and destination operands. The final program is just over 1000 lines of Python code including comments and blank lines.

Here is some sample output:

00000000  4E 71                          NOP
00000004  A2 34                          UNIMPLEMENTED
00000006  4A FC                          ILLEGAL
00000008  4E 70                          RESET
00000012  4E 40                          TRAP      #$00
0000001A  00 7C AA 55                    ORI       #$AA55,SR
0000002A  02 7C AA 55                    ANDI      #$AA55,SR
00000032  60 5E                          BRA       $00000092
000000BA  48 C2                          EXT.l     D2
000000BE  4E 69                          MOVE      USP,A1
000000DE  57 CF 00 22                    DBEQ      D7,$00000102
00000112  72 01                          MOVEQ     #$01,D1
00000146  EF 82                          ASL.l     #7,D2
000006E4  08 78 00 08 12 34              BCHG      #$08,$1234
00000C9E  4C FB 55 AA 90 12              MOVEM.l   $12(PC,A1),D1/D3/D5/D7/A0/A2/A4/A6
00000CF4  2C 6D 12 34                    MOVEA.l   $1234(A5),A6
00000D3A  18 3A 12 34                    MOVE.b    $1234(PC),D4
00000F24  55 91                          SUBQ.l    #2,(A1)
00001334  DF B8 12 34                    ADD.l     D7,$1234

With the -n or --nolist option, it only disassembles the instructions. This could be used to feed the output back into an assembler, if you were reverse engineering some code for example. Here is some sample output in this mode:

 NOP
 UNIMPLEMENTED
 ILLEGAL
 RESET
 TRAP      #$00
 ORI       #$AA55,SR
 ANDI      #$AA55,SR
 BRA       $00000092
 EXT.l     D2
 MOVE      USP,A1
 DBEQ      D7,$00000102
 MOVEQ     #$01,D1
 ASL.l     #7,D2
 BCHG      #$08,$1234
 MOVEM.l   $12(PC,A1),D1/D3/D5/D7/A0/A2/A4/A6
 MOVEA.l   $1234(A5),A6
 MOVE.b    $1234(PC),D4
 SUBQ.l    #2,(A1)
 ADD.l     D7,$1234

The source code and test program can be found here.

This process gave me an appreciation for the effort that the Motorola engineers must have gone through to implement the native 68000 dissasembler in the TUTOR firmware which was written in assembly language.

I can also appreciate that significant more work would be needed to extend this to support the 68020 or later processors which have more instructions and addressing modes.

While it was not meant to be a production program, it was fun to write and I now have a much better understanding of the 68000 instruction set and its complexity, quirks and limitations.

Sunday, September 29, 2019

Hugo Winner Book Review: Harry Potter and the Goblet of Fire by J. K. Rowling



Not many pure fantasy novels have won the Hugo award for best novel. One notable winner was The Sword in the Stone in 1939. This book, the fourth in the Harry Potter Series, won the award in 2001. This was the only one of the seven Harry Potter books to win a Hugo.

I was vaguely familiar with the Harry Potter franchise but had never read any of the novels or seen the films. I would say that the book lived up to my expectations and I can see why they were so popular with young people. Highly imaginative, well plotted, and with well developed characters, the books never talk down to the reader. At 636 pages in the hardcover edition, this book was over twice as long as the earlier novels (but exceeded by the subsequent book).

Given the popularity of the series, it is fitting that it won at least one Hugo award.

Wednesday, September 4, 2019

Hugo Winner Book Review: The Dispossessed by Ursula K. Le Guin



Winner of the 1975 Hugo for best novel, this is a fascinating story about an unlikely hero and two planets with widely differing political systems. It fits into Le Guin's Hainish Cycle, like "The Left Hand of Darkness" a Hugo winner I previously reviewed.

Highly original and imaginative, It describes an anarchist utopian society that almost had me convinced that it could work.

Recommended reading, it is a standalone novel that doesn't require having ready any of the other novels in the series.