Writing 8088 assembly on the Philips P2000C#

Roughly two weeks ago, I visited the Helmond Computer Museum and was extremely lucky to find they had a Philips P2000C up for sale. A so-called luggable, in a way a predecessor of current laptops, designed by the Philips electronics company. The computer hosts a Zilog Z80A processor running at 4 MHz.

../_images/philips-p2000c.jpg

A Philips P2000C, introduced in 1982.#

It was one of the later revisions (the P2012) equipped with 2x640kb floppy drives and a 16 bit CoPower expansion board hosting an Intel 8088 processor. Debatably, this could be considered as a “gateway” machine between the CP/M era and the MS-DOS era as the machine can run both and transfer files between the two types of operating systems.

../_images/p2000c-copower-board.jpg

The P2093 CoPower expansion card hosting an Intel 8088 processor.#

The P2093 CoPower board#

For the CoPower board, there are two floppies. One to boot the system into the CP/M environment after which the user can execute a secondary MS-DOS bootloader to boot into an MS-DOS environment. Booting the P2000C using the first floppy yields the screen as seen below.

../_images/IMG20240811170605.jpg

Boot screen when loading into the CP/M environment.#

By running msboot, the MS-DOS 2.11 bootstrap is loaded.

../_images/IMG20240811170635.jpg

By running msboot, the MS-DOS environment is loaded.#

One now inserts the second floppy into the first drive and the MS-DOS environment is loaded into the machine. In this environment, the memory on the expansion card is being used rather than the memory hooked up to the Z80. It is however possible to exchange data between the two processors (8088 and Z80) and even execute instructions on the Z80 while in MS-DOS mode.

../_images/IMG20240811170701.jpg

The MS-DOS v2.11 environment on the P2000C.#

Programming Hello world in 8088 assembly#

To showcase the MS-DOS environment, let us consider the DEBUG.COM program which comes bundled with many MS-DOS versions. Debug is a relatively primitive inline-assembler and deassembler. It can also perform memory dumps, read and write to floppy and drives and show the processor registers. In the example below, we will show how to write an extremely simple Hello World! program in 8088 assembly, store it as a HELLO.COM file on a floppy disk and run it.

  • To start, run the Debug program by executing debug

  • Type a and hit enter to enter inline assembly mode.

  • Copy the instructions as shown below

mov ah,9
mov dx,109
int 21
int 20
  • After typing int 20, hit enter twice to exit the inline-assembler mode.

  • Now type e 109 "Hello World!$" to write the string Hello World! starting at memory position 0x109. The $ acts as a terminating character.

  • At this point, the program has been entered in memory and we can save it to a floppy drive. To do so, we need to set in register CX the amount of bytes to write. This correspond to 0x16 bytes, which we can enter by first typing r CX which reads out the current value of the CX register and allow us to provide a new value. Enter 16.

  • Besides the number of bytes, we also need to specify a filename, this is done using n b:hello.com.

  • To start the write procedure, type w and hit enter. The program will respond that 0x16 bytes have been written. You will also hear the floppy drive writing the data to the disk.

../_images/IMG20240811173345.jpg

Assembly (8088) listing of a simple Hello World program.#

At this point, one can do two things. One can run the program directly from the debugger by running g or alternatively, one can exit Debug by typing q and run the program directly from the MS-DOS environment. We will be doing the latter. After exiting the debugger, we type b: to go to the second floppy drive and run dir/w to see what files are stored there. Finally, we run HELLO.COM by typing hello. As can be seen, the Hello World! string is outputted to the terminal.

../_images/IMG20240811173410.jpg

Running the “Hello World” example via the HELLO.COM executable.#

Relevant reading material#

Before one gets the impression that the P2000C has a fully-fletched 100% compatible MS-DOS system, it has not. Not all interrupt routines are recognized and some specific interrupt routines that interface with specific hardware will simply not work. Before programming anything in 8088-assembly on the P2000C, it is warmly recommended to read the manuals. A very large collection of manuals can be found here. Specifically, the P2093_CoPowerBoard0-8.pdf and P2093_CoPowerBoard9-10.pdf are two important must-reads which can be found in the aforementioned archive. Another userful resource is this Interrupt Services overview.

Final remarks#

Although Debug is readily available, its useful is rather limited when writing assembly. For one thing, it has no support for labels. The displacement addresses for call or jmp routines have to be calculated manually, which can readily become a big chore. For anything larger than, lets say, 100 bytes of instructions, it is better to use a more capable assembler. Many free native 8088 assemblers exist.