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.

Saturday, August 3, 2019

Hugo Winner Book Review: Where Late the Sweet Birds Sang by Kate Wilhelm




This was the 1977 Hugo award winner for best novel.

It is a near-future apocalyptic tale with some aspects that are disturbingly familiar today (e.g. pollution, climate change, new diseases, genetic engineering).

The writing style is quite different from most of the classic SF authors, with much focus on characters and their emotions. I found it somewhat reminiscent of John Wyndham's work.

An enjoyable novel, unpredictable and disturbing at times, I think it was well deserving of the award

Wednesday, July 10, 2019

Hugo Winner Book Review: Foundation's Edge by Isaac Asimov


Isaac Asimov wrote the award winning Foundation trilogy, originally as a series of eight short stories published from 1942 through 1950, and then in the form of three novels. One portion, "The Mule", won the Hugo in 1946. The trilogy won a Hugo for "Best All-Time Series" in 1960.

Despite requests from fans, he wrote no more books in the series until 1982 with the publication of Foundation's Edge. The novel, winner of the Hugo award in 1983, continued the series and took place after the events of the first three books.

I believe what got Asimov motivated into writing a sequel was the challenge to tie the Foundation series in to many of the other novels he had written subsequently. He is able to weave into this novel references and themes from his novels The Stars, Like Dust, The Currents of Space, Pebble in the Sky, The Caves of Steel, The Naked Sun, The End of Eternity, and his robot stories.

Like the original series, the book is not for everyone. It is heavy on dialog, has many characters, and a plot that has many unexpected twists and turns. Readers looking for space battles, monsters, and aliens will be left wanting.

I read this novel some time ago, but read it again as part of the Hugo award reading challenge. I thoroughly enjoyed it.

Asimov subsequently wrote more novels in the series, but he never again won a Hugo for best novel.

Sunday, June 30, 2019

Hugo Winner Book Review: The Fountains of Paradise by Arthur C. Clarke


I started this journey of reading Hugo award winning novels with books that were written well before I was born. Over 30 novels in, I'm now up to the Hugo award for best novel in 1980, the year that I got married.

Isaac Asimov is my favorite science fiction writer, but when Arthur C. Clarke was writing at his best, I think he was a better writer. This novel is Clarke at the top of his form. Based on the idea of a "space elevator" (one which is theoretically possible and likely to happen some day) it has all the hallmarks of his writing including an exciting and imaginative story with many excellent little details. The characters are also a little more developed than in most of his stories.

A hallmark of his writing seems to be contact with extraterrestrials, often highly advanced. This was not part of this story but he adds a subplot plot on this topic that gets weaved into the main story.


Wednesday, June 26, 2019

Hugo Winner Book Review: Dreamsnake by Vonda N. McIntyre


Winner of the Hugo award for besr novel of 1979, this is a touching and beautiful story with an original and imaginative plot, well developed characters, and a fascinating science fiction setting. It is science fiction at its best, where the plot and characters are primary. Earlier dominated by men, by 1979 the Hugo awards were being won about half the time by women, and in recent years women have almost entirely dominated the best novel awards. This is highly recommended ready for anyone, whether science fiction fans or not.

Wednesday, June 19, 2019

Hugo Winner Book Review: Gateway by Frederik Pohl



This novel won the Hugo award for best novel of 1978.

I enjoyed it, finding it an eclectic mix of science fiction themes with interesting characters and a very imaginative premise. It later became part of a series of novels and stories around a similar theme: the mysterious alien Heechee race.

The novel makes use of an interesting device in that many pages contain standalone text for signs, legal documents, classified ads, and even some kind of BASIC-like computer programming.

Pohl was a life-long friend of Isaac Asimov, and even acted as his literary agent for a period of time. The book has some references to a "Dr Asmenion" who was an expert on explaining science and astronomy and likes to tell off-colour jokes and was apparently from somewhere near Smolensk, Russia. This is clearly a little jab at Asimov. Another letter is written by a "Harry Hellison" that sounds suspiciously like science fiction writer Larry Ellison.

Pohl had a long career as a science fiction writer and editor, active right up to the time of his death in 2013 at age 93, but this was his only Hugo award winning novel (he did won some more Hugos in other categories).

Tuesday, June 11, 2019

Hugo Winner Book Review: The Forever War by Joe Haldeman


This won the Hugo for best Science Fiction novel in 1976.

It is about a long running war that is far away, fought by conscripted soldiers who don't want to be there, and ultimately turns out to be pointless and unnecessary. While definitely science fiction, it has many parallels with the Vietnam war that the author served in.

Not a humorous or particularly pleasant novel, it is highly imaginative and makes one think about war and even the future of mankind. The Earth depicted in the early 21st century has many disturbing parallels to the world of today and where it might be headed.

In summary, a fascinating read that was well deserving of the Hugo, particularly as the author went through 18 publishers before he found one willing to publish it.

Sunday, June 2, 2019

Hugo Winner Book Review: Rendezvous with Rama by Arthur C. Clarke



This was the Hugo award winner for best novel of 1974. It also won the other major science fiction award, the Nebula.

This is one of Clarke's best novels in my opinion, and has all the hallmarks of his work: incredible imagination, a sense of wonder, and a theme found in almost every one of his novels: contact with intelligent aliens. It also has what some find annoying: he doesn't explain everything, leaving many questions unanswered and up to the reader to ponder.

The novel spawned three sequels, which were written by author Gentry Lee (with some input from Clarke).

Wednesday, May 29, 2019

Hugo Winner Book Review: The Gods Themselves by Isaac Asimov



This novel won the Hugo award for 1973.

I had read it before, but it is one of Asimov's best novels and as it had been some years since reading it, I decided to read it again.

I remember reading in Asimov's autobiography that the genesis of this novel was a criticism that his stories didn't feature non-human aliens or sex, so he was determined to write a novel with very alien aliens and (alien) sex.

The novel is in three distinct parts: the first takes place on Earth, the second in a different (parallel) universe, and the third takes place on a future colonized moon.

It is a standalone novel that doesn't fit into his robot or Foundation series, and in my opinion was Asimov in his prime. There were some similarities in his depiction of lunar colonies with books by Robert A. Heinlein, but I think this just reflected the general thinking of most science fiction authors of that era about where future colonization of the moon could go.

He also put in some political intrigue among scientists, vying for fame and backstabbing each other, that is likely based on some of his experiences as a scientist and academic.

Thursday, May 23, 2019

Hugo Winner Book Review: To Your Scattered Bodies Go by Philip José Farmer


Another thoroughly enjoyable novel, this won the 1972 Hugo award for best novel.

It was an easy read that I completed in just a few sittings. The style reminds me somewhat of older authors like Jules Verne and H. G. Wells, perhaps because the hero was a man from the late 19th century. In fact the main character is a man of so many abilities, like speaking dozens of languages, that I would have said it was a flaw in the book that made him unbelievable if it were not for the fact that Richard Francis Burton was an actual historical character.

The book has a novel premise, interesting characters, gripping plot, and ended up becoming a series of five novels and several short stories.


Monday, May 20, 2019

Hugo Winner Book Review: Ringworld by Larry Niven



This was the Hugo award winner for best novel in 1971.

Considered a classic, the Ringworld is a mysterious alien megastructure millions of miles in size. This first novel spawned a number of sequels and prequels.

I thoroughly enjoyed this novel, particularly the concept of the Ringworld, but also the plot and characters.

The first edition had a number of technical errors in it, most notably the idea of travelling eastward around the Earth in order to extend the date of a  birthday, when in fact one would need to travel west to do this. Regarding this, Niven wrote, "If you own a first paperback edition of Ringworld, it's the one with the mistakes in it. It's worth money." Sure enough, my copy (pictured above) is indeed a first edition paperback.

Tuesday, May 7, 2019

Hugo Winner Book Review: The Left Hand of Darkness by Ursula K. Le Guin


This was the winner of the Hugo Award for best novel of 1970, and the first Hugo won by a woman author. I thoroughly enjoyed this novel - it is highly imaginative and original with a gripping plot and well-developed characters. The author describes an entire planet in great detail, with a detailed culture and even describing their calendar and time system. The people of the novel are androgynous, and it raises many interesting questions about the concept of gender, something that is very timely today.

This was the first Le Guin novel I recall reading, and I look forward to reading her 1975 Hugo winning novel in the future.

Friday, April 19, 2019

Hugo Winner Book Review: Stand on Zanzibar by John Brunner



I really want to like this book, but at 72 pages in I had to set it aside.

It reads more like a series of short scenes, rather than a novel, with little connection between them. While the author makes some rather interesting and accurate predictions about life in the future, I couldn't really find a plot or characters that I cared about.

At a little over 10% of the way through the novel's 650 pages, I called it quits for now, the first time I've done this for any Hugo award-winning novel. I will make another attempt to complete it at a later date.

Setting it aside, I picked up a copy of Heinlein's The Puppet Masters, was hooked within the first few pages, and finished it in a few days. Not a Hugo award winner, it is one of his better novels, avoiding most of the preaching or attempt to shock of some of his books.

Next up, I am reading Small Fry, a memoir by Lisa Brennan-Jobs, daughter of Steve Jobs. It is an easy and enjoyable read and provides insight into Steve Jobs from a slightly different perspective than some other books written about him.

Sunday, April 14, 2019

A 6809 Single Board Computer: Instruction Trace/Step Function

In my JMON monitor for the 6502, I implemented a trace or step function where you can execute code one instruction at a time and see the results of execution on the CPU registers. This is very useful for debugging, particularly as this implementation supports stepping through ROM code, something that can't be done with breakpoints.

For my 6809 single board computer I wondered if I could do the same for the 6809 processor. After some thought, it looked feasible, although more challenging as the 6809 has a larger and more complex instruction set than the 6502.

The basic idea is to take the instruction to be executed and store it in a buffer in RAM. The values of all CPU registers from the previous instruction trace are restored and the instruction is executed. A jump instruction is placed right after the traced instruction that goes back to the trace program. After execution, the new register values can be displayed and saved. This allows running code that is in ROM, as it gets copied to RAM when executed.

To implement this requires knowing the length of each instruction, as they can vary on the 6809 from one to five bytes depending on the instruction and addressing mode. From my previously written disassembler I already had code that could determine the instruction length and even disassemble it.

A wrinkle in this approach is handling instructions which cause a change in the flow of execution, such as a JMP (jump) instruction which would not return if simply executed in the buffer. We need to handle this instruction as a special case. We can examine the destination address and update the saved program counter accordingly. We don't need to actually execute it since it changes no other registers than the PC. We do need to check for and handle both direct (8 bit) and extended (16-bit) jump instructions. For direct, the destination address needs to be calculated by combining the instruction operand with the current value of the direct page (DP) register.

Jump to subroutine (JSR) in another special case. Here we need to push the return address on the stack (using the saved value of the stack pointer that we trace with) and then calculate the new PC value.

Similarly, we can handle BRA/LBRA and BSR/LBSR like JMP and JSR but the effective address needs to be calculated by adding the offset to the current PC value. Again we don't need to execute the instruction, just update the new PC value.

The interrupt related instructions SYNC, CWAI, SWI, SWI2, and SWI3 can all be simulated by pushing registers on the stack and setting the PC to the appropriate interrupt vector.

RTS and RTI are simulated by pulling registers (in the case of RTI) or just the PC (for RTS) off the stack. One wrinkle is that in the 6809 we need to check the E (Entire) flag in the condition code register to know of we should restore all registers from the stack.

Conditional branches are a little more tricky. They can transfer control to two different places depending on whether the condition is true or not. These are handled by writing into the execution buffer both the instruction being traced as well as different jumps depending on whether the branch is taken or not. The branch destinations can update the PC accordingly. The code in the buffer looks like below:

XXXX XX 03           Bxx $03 (Taken)         ; Instruction being traced
XXXX 7E XX XX        JMP BranchNotTaken
XXXX 7E XX XX Taken  JMP BranchTaken

We execute the instruction in the buffer and let it perform the test. We need to handle all the possible branch instructions, both short and long versions.

TFR (transfer) and EXG (exchange) instructions are okay to run except the cases where the source or destination is the PC. We need to handle those cases manually since it would otherwise change the flow of control.

Similarly, PSHS/PHSU and PULS/PULU could potentially include the PC in the list of registers pushed or pulled. Currently I just check for this case, remove the PC from the list of registers, and warn the user in this case that it is not fully handled yet.

Indexed addressing poses a challenge: we need to handle an instruction that changes flow of control like JMP 1,X with an arbitrary index addressing mode. It might also produce side effects in the case of instructions like JMP 1,X++. These are handled using a trick: instead of JMP, we run a LEAU instruction with the same indexed operand. Then we examine value of U, which should be the new PC. Currently the code can't handle addressing modes that change the U register like JMP ,U++.

A final challenge is PCR relative index addressing. If we move the instruction to the buffer to execute it, the PC relative address is now wrong. I thought about this, and it should be possible to adjust the offset based on the difference between the original instruction location and the address of the buffer where it will be run. This would get a little complicated, so I didn't implement it (yet). For now I just ignore it and display a message at run time that it is not supported.

After working out most of the logic as pseudocode, I implemented and debugged it. I started with the basic instructions and then added all of the special cases, testing them one at a time. Once done, I tested it with some smaller complete programs.

Finally, I was able to integrate it into the "combined" ROM which also contains the ASSIST09 monitor, disassembler, and Microsoft Basic. I added the trace command as a new ASSIST09 "T" command. It took some shuffling but I was able to just get them all to fit in the 8K ROM.

It hasn't been tested exhaustively, and it can't run BASIC because it uses some PC relative instructions, but it seems to work quite well. Here is some sample output:

>T D000
D000  81 30        CMPA  #$30 
PC=D002 A=FF B=FF X=FFFF Y=FFFF S=FFDF U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D002  25 04        BCS   $D008 
PC=D004 A=FF B=FF X=FFFF Y=FFFF S=FFDF U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D004  81 3C        CMPA  #$3C 
PC=D006 A=FF B=FF X=FFFF Y=FFFF S=FFDF U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D006  25 C0        BCS   $CFC8 
PC=D008 A=FF B=FF X=FFFF Y=FFFF S=FFDF U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D008  30 1F        LEAX  $1F ,X
PC=D00A A=FF B=FF X=FFFE Y=FFFF S=FFDF U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D00A  34 50        PSHS  U,X
PC=D00C A=FF B=FF X=FFFE Y=FFFF S=FFDB U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D00C  0F 41        CLR   $41 
PC=D00E A=FF B=FF X=FFFE Y=FFFF S=FFDB U=FFFF DP=FF CC=11111000 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D00E  CE C0 E7     LDU   #$C0E7 
PC=D011 A=FF B=FF X=FFFE Y=FFFF S=FFDB U=C0E7 DP=FF CC=01111110 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D011  0F 42        CLR   $42 
PC=D013 A=FF B=FF X=FFFE Y=FFFF S=FFDB U=C0E7 DP=FF CC=01111110 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT  
D013  33 4A        LEAU  $0A ,U
PC=D015 A=FF B=FF X=FFFE Y=FFFF S=FFDB U=C0F1 DP=FF CC=01011001 (EFHINZVC)
PRESS TO CONTINUE, TO QUIT 

References

  1. https://github.com/jefftranter/6809/tree/master/sbc/trace
  2. https://github.com/jefftranter/6809/tree/master/sbc/combined
  3. https://github.com/jefftranter/6809/tree/master/sbc/disasm
  4. https://github.com/jefftranter/6502/tree/master/asm/jmon