A file transfer program for the P2000C / CoPower board#

In the previous two blogposts I discussed how we can use the serial port on the P2000C to exchange data between the venerable P2000C and a modern computer. So far, we were mainly exchanging short message strings, but a more valid use case is to transfer program files from a modern computer to the P2000C such that we can run these programs on the P2000C. This would also allow for cross-compilation on a modern computer and run the result on the P2000C.

For this very purpose, I have created a program called “Byte Bridge”. The source files and installation instructions can be found in this Github repository. Byte Bridge is combination of two programs, one residing on the P2000C and another, in the form of a Python script, residing on the modern computer. I opted for Python as it hopefully provides the best compatibility between the various modern computer architectures out there. An example of running the Byte Bridge program is shown below.

../_images/p2000c-bytebridge-transfer.jpg

Interestingly, to get Byte Bridge to work on your P2000C, you are running into a so-called chicken-egg kind of problem. How do you transfer the file BB.COM file to your P2000C which requires a program such as BB.COM? The MS-DOS suite for the P2000C does not have such a program. If it would, there would be no need for a program such as Byte Bridge. To tackle this problem, we turn back to our handy program DEBUG.COM and use a very small “bootstrap” kind of program. It will do exactly what it is supposed to do, but only that, making it very small in size and thus ideal for typing it in by hand.

This “bootstrap” program is shown in the listing below. It first reads two bytes over the serial port and store these as a 16-bit unsigned integer in the CX register. These two bytes correspond to the number of bytes the program has to receive. Next, the program is placed inside a loop which will retrieve the number of bytes stored in CX and store these starting at memory position $200. Since our bootstrap resides at $100-$118, this will not interfere.

0A4C:0100 B402          MOV     AH,02
0A4C:0102 CD14          INT     14
0A4C:0104 88C1          MOV     CL,AL
0A4C:0106 B402          MOV     AH,2
0A4C:0108 CD14          INT     14
0A4C:010A 88C5          MOV     CH,AL
0A4C:010C BF00002       MOV     DI,0200
0A4C:010F B402          MOV     AH,02
0A4C:0111 CD14          INT     14
0A4C:0113 8805          MOV     [DI],AL
0A4C:0115 47            INC     DI
0A4C:0116 E2F7          LOOP    10F
0A4C:0118 CD20          INT     20

On the modern computer, a Python file called bootstrap.py is used to send over the file. Default settings are used everywhere, corresponding to a BAUD rate of 1200, no parity checking, using a single stop bit and using a transfer length of 8 bits.

Upon execution of the program (see also the detailed instructions on the Github repository if you want to do this yourself), the file is placed in memory. The next step is to store the file from memory onto a storage medium such as a floppy disk. The DEBUG.COM program has this functionality nicely built in. First, one needs to write the number of bytes to be stored in the CX register. This is accomplished via the R CX instruction. Next, a filename is specified using the n <FILENAME> command (e.g. n b:bb.com). Finally, the data can be written via w 200, which informs the program to start writing the number of bytes stored in the CX register, starting from memory location $200 to the file specified by the n command.

Upon completion, there is now a file called BB.COM residing on the B drive. Upon execution of this file, we can put the computer in a waiting state (for a maximum of 20 seconds) and initiate the file transfer on the modern computer side via the upload.py script. The BB.COM program has a much richer functionality than our simple “bootstrap” program. It not only reads the number of bytes, it also accepts a filename and a checksum. The latter ensures that once all the bytes are received, it can be validated whether these bytes are all correct. If so, the BB.COM will automatically store the file to the floppy disk, using the filename as specified in the upload.py script. The whole process becomes now relatively easy, requiring minimal action of the user.

To test Byte Bridge, let us download a small and cute game called Avoid the Awful Thing that Vaguely Resembles a Banana!! by Curtis Smith, Thomas Karrmann, and Jack and Alice Evans. The game can be found via this link. We place the AVOID.EXE file in a convenient folder on our modern machine and run BB.COM on the P2000C. The file transfer proceeds and after a short amount of time, we can see on the P2000C the result as shown in the image below.

../_images/p2000c-bytebridge-transfer-example.jpg

With AVOID.EXE successfully being written to the floppy drive, we can now open the game. As you can see, we can play the MS-DOS game Avoid the Awful Thing that Vaguely Resembles a Banana!!.

../_images/p2000c-bytebridge-game-example.jpg