Home

Z80  Programming

TRS-80 Assembly-Language Programming

Overview

Someone in some group chat suggested I read Radio Shack's TRS-80 Assembly-Language Programming (1979) if I wanted to learn Z80 Assembly on my own. I found a .pdf version online but ended up buying a worn-out paperback version of the book on eBay simply because the quality of the .pdf left something to be desired. I appreciate someone taking the time to archive the book (as a series of photos) to .pdf but it was just too hard to read, hence the book purchase.

Anyway, I found it very helpful in getting a handle on Z80 Assembly programming. Do yourself a favour/favor and don't skip the first 3 chapters because you think you already know the material. Just sayin'... Almost forgot: I liked the book and the next two in the series. They're listed below under the image.

 

Some things you need to know while getting started:

1) Back in '79 the book's author (William Barden Jr.) coded on a TRS-80 Model I which used a cassette tape recorder for storing programs, so you may not be able to easily find his demo code online. Not to fear, I have saved the book's exercise programs I typed in; you won't need to type them in.

2) The programs were originally written by Barden using Radio Shack's Editor/Assembler and debugged with TBUG. You will probably want to use your own editor like Programmer's Notepad, or the one built into OshonSoft Z80 Simulator IDE when you press <CTRL>A. For an Assembler, there's OshonSoft's as well as TASM v3.2.

3) All of Barden's programs finish with an endless loop: it's not necessary if you're running a simulator. I've included the loop in the code as per the original listings but it's commented out. Standing in its stead is the Z80 HALT instruction that will not stop your computer if the program is run in an integrated development environment (IDE) like OshonSoft's product.

4) The first free user area in the TRS-80 address space appears to be 4A00h. If you want to see everything that's going on when you run your code, you may be bouncing between screens to get at the address spaces used. I rewrote many of the programs such that they run at 0000h, not 4A00h. Here's a screenshot of OshonSoft's Memory Editor with the TRS80-Page121.asm program loaded as TRS80-Page121.obj. I've included the TRS80-Page121.lst listing file, too, if you want to see how the code is organized with three .ORG statements included in the file. In the original code the source and destination addresses were at 4A00h and 4B00h. The entire program was less than 30h bytes in length as you can see below (in the screenshot) so I changed the source and destination addresses to 0050h and 0040h, respectively. You can now see the 4 source bytes at 0050h and the 4 destination bytes at 0040h.

These are simple changes that make examining the code and results so much easier.

Z80 Assembly programs by William Barden Jr.

Here's a link to the programs used in TRS-80 Assembly-Language Programming (1979) Radio Shack #62-2006.

 

Even more Assembly programs by William Barden Jr.

Here's a link to the programs used in More TRS-80 Assembly-Language Programming (1982) Radio Shack #62-2075

Here's a link to the programs used in TRS-80 Assembly-Language Subroutines (1982)

 

Assembly programs from other contributors

Link 4

Link 5

 

TRS-80 Emulator

If you would like to run the .asm source code files on the original TRS-80 computer, you're going to need an emulator if you don't have the real thing.

Sharp80 is an excellent TRS-80 Model III emulator with its own built-in ROMs so you don't have to worry about copyright infringement.

Do note that during installation you may get an antivirus warning. As per the emulator's author, just restart the program and it should go away but not always.

 

OshonSoft Z80 Integrated Development Environment (IDE)

Speaking of OshonSoft from earlier, they have an excellent set of tools if you're learning assembly programming, regardless of CPU. You can try their Z80 product online for half-an-hour each day for a fixed number of days to see if it's going to work for you. The author has a good user manual with several demo programs for you to try. I knew after the first couple of sessions that it was worth the 25 Euros he was charging. Here's a link to the Z80 Simulator IDE as well as the general site.

 

How does the OshonSoft Z80 Simulator work? Here it is in a nutshell:

 - Startup Z80 Simulator IDE

 - Click Tools | Memory Editor

 - Click Tools | Assembler

 - Type in your program ensuring you have tabbed white space (Assembler | Options |  Editor Setup | Assembler Editor | Tab Size | 4) before you start your instructions

 - If you're going to use my typed-up programs, try File | Open instead

 - In Assembler, Tools | Assemble & Load. You should see the machine language in the Memory Editor

 - In Simulator, Rate | Step by Step

 - In Simulator, Simulation | Start

 - In Simulator, Simulation | Step. Continue to press <F2> to Step through each line of assembly code

 - When finished, Simulator | Simulation | Stop. This is an important step or things will get confusing when you try to load up other code

There are a lot of features that I have not touched on. What you see above is all you need to get started. Start the simulator, load the programs I have provided, read the pdf/manual, and learn Z80 Assembly Language programming.   :-)

 

TOP

 

Home