First custom program for EPS-103
The next logical step in trying to modify the EPS-103 is to write a short program that could be run in the unit. Of course, we will not start by rewriting the original firmware. At this point, we'll just try out the entire program development process on something simple. Programming textbooks usually start with "Hello world". We will stick to tradition and write a program that will write this inscription on the display when the EPS-103 is turned on.
Choosing a programming language is generally simple. Due to the size of EPROM and RAM, it will be assembler. Forget about C or any higher programming language. Even with optimizations turned on, their code will always be longer. Another reason for using assembler is the fact that the original firmware still has its data in RAM, which we must not damage. Therefore, it is necessary to have full control over the written program.
TThis means that we need to know the 8085 assembler. This does not mean that we need to have all the instructions memorized. But some documentation would certainly be useful. You can find a lot more on the internet. Unfortunately, the 8085 processor is very outdated from today's point of view, and not much information about it has been preserved. That's why I've prepared some basic documents to help you get started. You can find them in the overall SDK8085.zip file. Another helper can be a simulator. To my surprise, we can still find an 8085 simulator online today. As you step through the program, you will see how individual instructions affect the contents of the registers.
Any text editor will be sufficient to write the program. It is only important that the editor does not add any of his own tags to the written text. I like to use PSPad. We will leave the use of the integrated development environment for later.
And it's time to start writing the source text. Of course I was inspired by the original firmware. The most important thing is setting the stack to the correct address in RAM. This ensures that instructions using the stack do not overwrite another part of memory. That's why we'll start with that. I further assume that some of you will be doing these experiments with the EPR-203 motor unit attached. Therefore, in the next step it is necessary to initialize the 8255A circuit and set the PC output to 0. This means turning off the motors. Then we can initialize the display and send an inscription to it. We end the program execution with an infinite loop. Or HLT instructions. In assembler, such a program might look like this:
; Hello world
mystring .text "Hello world"
Start: lxi sp, 4700h ; Set Stack Address
mvi a, 82h ; CW
sta 5803h ; 8255A Write Control Word
sta 5802h ; 0 -> PortC: stop motors
mvi a, 0Ch ; LCD Command: Display on, cursor off
call sub_1B70 ; Command -> LCD
lxi h, mystring ; Address of text
mvi b, 0Bh ; Number of characters
Loc01: mov a, m
call sub_1B77 ; Character -> LCD
inx h ; Address of next characters
dcr b ; Decrement counter
Stop: jmp Stop ; Neverending loop
hlt ; For sure
; Write 1 byte command
sub_1B70: call sub_1B7E ; Wait for LCD ready
sta 4802h ; Write command byte
; Write 1 byte data
sub_1B77: call sub_1B7E ; Wait for LCD ready
sta 4803h ; Write data byte
; Wait for LCD ready
sub_1B7E: push psw
loc_1B7F: lda 4800h ; Read LCD status
ani 80h ; Test bit 7: 0 = ready
jnz loc_1B7F ; if not, repeat
We save the text in a *.asm file in any of our working directories. The next step will be to translate the source text into machine code. This is usually done via the object file *.obj. The target machine code can also be in *.bin format. The program that will do this work for us is called a compiler / linker. I used the program tasm.exe. In the tasm32.zip file you will find two instruction set tables and documentation. Add the program to the working directory. It can be run in windows command line including Win10. The actual translation is done with the command:
TASM.EXE -t85 -b Test01.asm Test01.bin
The given parameters mean:
- -t85: uses the 8085 processor instruction table from the TASM85.TAB file
- -b: creates a clean machine code binary
- Test01.asm: the name of the source text file
- Test01.bin: the name of the output machine code file
To start the translation, you need to open a command line window and switch to our working directory with the compiler and source text. To simplify my work, I wrote a simple file to run Run.cmd. Thanks to it, I don't have to start the command line window manually. The file is in the working directory and the command for translation is written on the first line. On the second line I typed
cmd /k which causes the command prompt window to not close itself. So after the translation is finished, I can read any error messages. So I have these files in my working directory:
The resulting binary file is loaded by the programmer into the erased EPROM memory. And that's all. When you want to make any changes in the program part of the firmware, you already have the basic necessary tools at your disposal. You can download all the files described here in one SDK8085.zip package.