CP / M-80 on the clone of the Quorum Spectrum

    I have on my memory window a large pile of five-inch floppy disks from a computer that my parents gave me when I was three years old, and from which I could only transfer to a PC at 14. This is Quorum-128, our Uralian Spectrum clone. The clone is quite interesting and significantly different from, for example, the Ural “Magik”. He worked with a tape recorder, like any other Spectrum, but when connecting the Quorum drive controller, it was not so easy to get it! - He knew how to work in OS CP / M-80. That's what I want to talk about this OS and its implementation on the Quorum today.





    A bit of theory: Spectrum without CP / M


    Let's start by recalling the architecture of the classic Spectrum - to understand how different CP / M is from it. I apologize in advance for possible inaccuracies - all this was a very long time ago.

    Spectrum-48 is assembled on a Z-80 processor with 8-bit registers and 16-bit addressing. The Spectrum had 16 Kbytes of ROM occupied by the interpreter of the BASIC dialect, which served simultaneously as the operating system for the machine; and 48 Kbytes of RAM, of which 6.75 Kbytes were taken up by video memory with a very specific addressing, into the device of which we are not going to go right now. The shared memory card looked something like this:



    Of course, BASIC programs on a processor with a frequency of 3.5 MHz slowed down completely, and all normal dudes wrote in assembler then, and programs on BASIC usually played the role of a loader, which loads assembler modules from the cassette to the given addresses and transfers control to them. (Real boys and bootloaders had tricky assembler ones, but not the point.)

    Spectrum-128, as you might guess, expanded the total RAM of the machine from 48 to 128 Kbytes (and added the musical co-processor AY-3-8910 / 12, which in the second half of the 90s was already a severe deficit, and in my Quorum it did not appear). But since the 128 Kbyte address bus didn’t fit into the 16-bit bus, a special, not very convenient system was used: all the memory was divided into 8 banks of 16 Kbytes, and any one could “imprint” any upper 16 Kbyte address space (0xC000-0xFFFF) from these 8 banks, outputting a special value to port 0x7FFD. (Yes, the memory areas 0x4000-0x7FFF and 0x8000-0xBFFF were also ordinary memory banks - I don’t remember the numbers now - and in 0xC000-0xFFFF it was possible to mirror them.) In addition, there were two ROM banks in the Spectrum-128 - with a classic interpreter Basic, and with a more advanced,

    Finally, there were a number of different drive controllers for the Spectrum, of which the Beta Disk Interface became the most popular (and the only one used in Russian clones of the Spectrum). He added another bank of ROMs to the Spectrum, which was switched on in hardware instead of the usual one and seized control when going to the addresses 0x3D00-0x3FFF, if I was not mistaken. The controller ROM contained a very primitive TR-DOS disk operating system, which worked with 640 KB floppy disks and was controlled by commands similar to BASIC commands. The controller also had a special Magic Button, when pressed, a full memory dump was written to the disk (48 Kbytes - I did not know about Spectrum-128). This allowed instead of making a full adaptation of the Spectrum programs and games to the drive, just download the program from the tape, press the button and reset to disk. Then you could already boot it from a floppy disk. Of course, if the program had, for example, a save and write function, then they continued to work with the tape, but overall it was very convenient.

    Operating System CP / M-80


    The CP / M-80 was developed for machines powered by Intel i8080 processors and its compatible Zilog Z-80s by Digital Research in the 1970s. CP / M stands for Control Program for Microcomputers; The suffix -80 officially appeared in the name only when CP / M-86 appeared for PC and 8088/8086 processors. Before the PC quickly began to gain popularity, the niche of personal, relatively low-power computers was occupied precisely by machines with CP / M-80.

    CP / M-80 was one of the first operating systems in the modern sense. It was in it that such a feature as the abstraction of programs from physical equipment appeared, and this was the reason for its (relative) popularity. CP / M-80 consisted of three memory modules: CCP (Console Command Processor - primitive command interpreter), BDOS (Basic Disk Operating System - implementation of system calls) and BIOS (Basic Input / Output System - drivers of standard devices: disk, console, printer, and serial interface). When porting CP / M to a new machine, only the BIOS had to be rewritten; CCP and BDOS were device independent. Application programs could use the BDOS functions, or, if necessary, directly the BIOS, but were spared the need to know the wisdom of working with disk controllers of different machines.

    Of course, in practice, everything was not so smooth. The biggest omission of the BDOS / BIOS was the lack of any standardization of the output functions on the screen, except for the most primitive ones, which will work for a teletype terminal. As a result, programs that included functions, for example, a screen editor (like WordStar and Turbo Pascal), during installation offered to choose from several dozen machines known to developers, or, if there was no machine in the list, enter screen sizes and various control codes yourself to move the cursor, etc. Well, these are little things.

    The general memory card of the CP / M machine looked like this:



    Note again that this memory card will be valid on any machine with CP / M. Therefore, there are many uncertainties. There is no video memory, for example (and it’s not a fact that it will be present in reality - maybe the machine is generally connected to a teletype), but the only addresses whose contents are guaranteed are 0x0000-0x0100. To make a system call, you must put its number in register C, if I am not mistaken, and then execute the CALL 0x0005 instruction; the JMP instruction at 0x0005 will already go where necessary in BDOS. Also in this area are:
    • BIOS entry point (address 0x0000). This function reboots the machine, but with simple arithmetic you can get the address of any other BIOS function;
    • current disk number (A: = 0, B: = 1 ...);
    • the direction of the current input-output flows (for example, the console can be directed to a printing device, or to a serial port);
    • names of files (no more than 2) transferred to the loaded program as command line parameters in FCB data structures suitable as arguments to calling BDOS functions;
    • full command line of the current program (addresses 0x0080-0x00FF - no more than 127 characters).

    The volume of TPA (areas for downloadable programs) was also not guaranteed and, in principle, could, depending on the implementation, be anywhere from 10 to 52 KB.

    The CP / M-80 file system is significantly simpler than FAT, although it copes with its tasks quite satisfactorily. Files are stored with the names 8.3; creation / change dates are not stored (the availability of RTC-hours in machines with CP / M was not guaranteed); the file size is stored with an accuracy of 128 bytes with rounding up (the amount of space it occupies on the disk is up to 4 KB). There are also no directories, in general - CP / M was not designed to work with hard drives, and you can live with floppy disks. There was, however, a kind of surrogate called the "user area". These areas were numbered from 0 to 15, and in each of them separate files could be stored. They switched command USER n .

    Since we were talking about commands, there were few of them: DIR, SAVE, ERA (deleting files), REN (renaming files), USER, maybe I forgot one or two more. (SAVE performed a rather specific function - saving the contents of TPA to disk - if, for example, you started the debugger, loaded a program in it, kidnapped it, left and want to save the version that was still in memory.) An alternative command-line extension was popular for CP / M ZCPR3 interpreter, much more sophisticated. However, I myself have not tried it.

    In general, CP / M was very reminiscent of the early version of DOS, yes, in general, and no wonder - DOS was developed as a clone of CP / M. For CP / M-80 there were many applied software - office programs, development tools, utilities. But with the advent and rapid development of PC, all this quickly became irrelevant - like the CP / M-86 version, which failed to make any significant competition with DOS.

    The source code for CP / M of various versions and its system utilities (in assembler) is easy to find on the Internet.

    How to cross CP / M and Spectrum


    CP / M and Spectrum have only one thing in common that they work on the Z-80 processor. If we compare their memory cards, we will not see almost anything in common, and the peripherals expected on the CP / M and on the Spectrum machine are significantly different. Nevertheless, the creators of the Quorum were able to make a machine that can simultaneously work with CP / M, and like a fairly ordinary Spectrum. What had to be changed?



    First of all, in the Quorum, ROM interferes with us. There is no ROM in CP / M (although the BIOS may well be located in the ROM, the BIOS is not located at the very beginning, but at the very end of the addressed space, and its volume is much less than 16 Kbytes). Therefore, in the Quorum, the memory management port 0x00 was added, which allows you to switch the Spectrum-Quorum ROM to an additional 16 KB of memory at addresses 0x0000-0x3FFF. Therefore, by the way, the younger Quorum model is called not “Quorum-48”, but “Quorum-64” - there really are extra 16 Kbytes of RAM left specially for the CP / M mode.

    (Actually, “Quorum-64” is not the youngest model yet - before it there was either “Quorum BK-02”, or “Quorum BK-04”, which is a simple clone of the Spectrum and cannot launch CP / M .)

    In addition to the ROM, we are interfered with video memory, which will stick out with us right in the middle of the precious TPA space. So the second function of port 0x00 is switching the video memory addresses from the default 0x4000-0x5AFF to 0xC000-0xDAFF. In the second mode, the video memory will be squeezed in between the BDOS and BIOS, but they, adapted for the Quorum, know this, and the program will not need to know.

    Speaking of video memory - on the Spectrum there is only one video mode, 256x192 with 16 colors. (More precisely, 256x192 is the resolution of a monochrome image, which is then superimposed with color attributes at a resolution of only 32x24 - so there can be no more than 2 different colors in each section of 8x8 pixels. But these are details.) The text is displayed in 8x8 pixels, which gives 24 lines of 32 characters each - which is conveniently superimposed on the video memory structure, but frankly small for most practical purposes. Most non-adapted CP / M programs generally expect at least 80 characters in a string!

    Therefore, there are four modes for displaying text in CP / M Quorum - 42 characters per line (6x8 font), 51 characters per line (5x8 font), 64 characters per line (4x8 font) and 83 characters per line (3x8 font). By default, after loading, 42 characters are used per line:



    It looks pretty decent, in my opinion. The 4x8 font is stored in memory at the same time as 6x8, and, for example, in the displayed text file viewer you can switch to it with one F5 button:



    It’s very inconvenient, but you can adapt if you didn’t have the worst TV connected to your computer (Quorum, like all Spectrum, usually worked with a TV instead of a monitor). This mode is good for editing text for subsequent printing - text printed on a matrix printer with 64 characters per line looks pretty good.

    With the TTY51.COM and TTY80.COM commands, you can switch to 5x8 and 3x8 fonts. 3x8 - this is, of course, hellish hell - look at the screenshot from 4x8 and imagine that all these tiny letters also stuck together in one line without gaps between them. This mode was sometimes used to run programs that were not adapted for the Quorum (the Quorumites sold several floppy disks with utilities and development tools for CP / M that were simply downloaded from the Internet and recorded as-is).

    Well, a little about the disk part. The Quorum drive block, slightly smaller than the current Micro-ATX system, was made of solid steel thickness, painted gray, and had two five-inch bays. It was accompanied by a system diskette with a basic set of utilities and several games - in fact, the image of a newer version of this diskette is the only one I found for the emulator. After the purchase - a year ago in 1998 - he refused to work for me, which cost me ten years of considerable frustration; in the end we got it repaired under warranty. The block came across to me in a vertical version with a black five-inch drive "Electronics MS-6313" or something like that. The drive was very poor quality, floppy floppy disk. At Quorum, I changed it to a more adequate five-inch Panasonic, then put the second Mitsumi, and then changed the second to a three-inch Samsung. However, all the same, they all ate the floppy disks only on the road, and one day CP / M began to issue scary messages “BDOS ERR ON A: BAD SECTOR”.

    Unfortunately, for a long time I didn’t have either the drive unit or the Quorum itself, so I write from memory and take screenshots from the emulator :)

    Inside, in addition to the drive bays, there was a controller board with the KR1818VG93 chip traditional for the Spectrum clones, and a power supply . The vulnerability of the drive unit was the interface with the computer - a short wide cable stretched from the unit, at the end of which a heavy metal box dangled somewhere 8x8x1 cm with an interface board inside, which had to be put on the edge connector at the back of the computer; The quorum, like most Spectrum, was combined in one case with a keyboard. The reliability of such a connection was low.

    Floppy disks - both five-inch and three-inch - the drive understood exclusively in the format of Double Sided / Double Density, 800 Kbytes. Under DOS, they would be 720 KB floppy disks, but CP / M used its own formatting: 2 sides, 80 tracks, 5 sectors, sector size 1024 bytes. On boot floppy disks 20 Kb occupied OS; this was not visible from the file system, it just occupied the first two tracks. To work with three-inch floppy disks from the store, it was necessary to glue a hole on them (on the contrary to the one with a slider for write protection) with an opaque adhesive tape.

    Perhaps it was because of this formatting that disk access in CP / M was extremelyslow. This (along with insufficient screen resolution for working in full text modes) was, in my opinion, the main drawback of the system. Of course, floppy disks are not fast in itself, but they should quietly pull out a couple of tens of kilobytes per second; in CP / M on the Quorum, the real read speed did not exceed 2-5 Kb / s. This is not a hardware problem - everything works just as slowly even in the emulator, and TR-DOS will be noticeably faster. It was especially sad to copy anything between floppy disks in the presence of only one disk drive.

    On the software side, the CP / M Quorum of drives also actually supported only two. On Quorum-128, 64 Kbytes of extended memory were also used as the C: RAM disk, which could be very convenient, especially with such and such speed with the disk.

    The BDOS in the CP / M Quorum was slightly dubbed to make the user areas a little more practical and similar in appearance and on the principle of working with directories. The number of areas was increased from 16 to 32, areas with numbers> 10 were allowed to be called letters (10 = A, 11 = B ...), they added the current user area to the command prompt (it was A>, it became A: \ 0>), and added in the command line interpreter, the ability to run programs and specify files from other areas of the user (\ A \ FILE.TXT).



    In general, I can’t say that it was so very convenient. The surrogate remained a surrogate. Well, I guess it's better than nothing.

    Separately, it is worth mentioning the compatibility of CP / M Quorum and Spectrum games. This is a very important aspect - after all, after all, where would Microsoft now be, for example, without its sacred backward compatibility? :) For this task - seemingly insoluble - several solutions were also found, which we will discuss below.

    Quorumites - as I understand it, this is basically one person by the name of Karimov - did a great job writing a lot of utilities from scratch under CP / M Quorum (for example, NC.COM, a simple two-panel file manager), and adapting even more third-party software, starting with CP / M itself and ending with Turbo Pascal. I well remember how I went to them in my childhood to write floppy disks and ask accumulated questions. The Quorum company was located on the fifth, last floor of the Univerbyt shopping complex, which had not yet been a glamorous shopping center. Behind a heavy iron door, everything was littered with computers, drawings, parts, and various strange assemblies. Just a touch of a miracle. It is a pity that now there are no such places, and if there are, they will not be perceived.

    Software for CP / M


    On almost every quorum diskette, first of all, there was their classic couple - the NC.COM shell:



    And the text editor ED.COM:



    NC.COM was, as you might guess by its name, a variation on the theme of a two-pane file manager. Among its useful functions are working with user areas as subdirectories, copying files (the naked CP / M did not know how to do this, although it had some kind of simple external utility for that), viewing text files in KOI-8, KOI encodings -7, “GOST-basic” and dosovskaya CP866 (by the way, the main encoding for CP / M Quorum was chosen by KOI-8 - apparently, because when cutting the 7th bit, what old unadapted programs can sin, it turns more or less transliteration), and copying files to DOS floppy disks and vice versa - the last, except N C.COM, in my opinion, no one else knew how.

    ED.COM, despite the name, was more similar to Unix vi than ed (and strictly speaking, according to instructions, it was a version of a certain WordMaster). It, like vi, had two main modes - text input and command. Of course, the set of commands was much more modest than that of vi, but there was already the ability to create macros from commands and write them in .MED files. Here is one of the help pages, for example:



    ED.COM was suitable for a set of programs (although with such a brake disk subsystem as on the Quorum, the sequence “launched ED.COM - edited - came out - compiled - linked - started everything turned out - go to step 1” required patience of the glacier) and simple text files. In principle, I wrote in it all sorts of essays with formatting (without pictures, of course). This is done simply: take the instructions from the printer - oh, my CM-6337 is generally worthy of a separate post! .. - open the directory of control codes and insert them manually in the right places. Fortunately, dot-matrix printers, even SM-6337, usually use more or less compatible Epson-shaped control codes.

    From other software on the system diskette, you can mention FORMAT.COM, SGEN.COM (which writes the OS to the system tracks, and allows you to configure some cosmetic parameters), SUBM.COM (which executes .SUB files - some kind of .BAT, only without variables and any controls like if, loops, etc.) and POWER.COM, which allows you to dabble with drives at a low level.

    On the disks of the quorumites it was possible to write down (10 rubles each) a lot of interesting things, including:
    • The WordStar word processor , once a hellishly popular program, is almost a killer app for CP / M. WordStar made it possible to format text in a more adequate way than manually entering printer control codes, but on the text screen, of course, there was no talk of any WYSIWIG, and indeed it got into the Quorum screen of WordStar so-so. Its large panel of modes and tips at the top of the screen from a height of years suspiciously resembles ... Office 2007/2010 ribbon :)
    • SuperCalc Spreadsheet. Linux users can install the sc package available, or at least available on most distributions, and get a pretty close idea of ​​SuperCalc. It actually looked pretty good, but I never managed to figure out why I might need spreadsheets.
    • Microsoft BASIC-80 . Yes, yes, the one with whom Bill Gates went to success. The quite adequate dialect of BASIC, in terms of functionality, is a cross between Spectrum BASIC and QBASIC, which we passed at school. The BASIC-80 had a built-in line editor, which wasn’t a godsend how convenient, but a much better editor-compiler-run cycle. The program debugged in the interpreter could be compiled by the BASCOM.COM compiler, and then linked with runtime and, if desired, with assembler procedures.
    • Microsoft M80 More or less standard assembler i8080 / Z-80 for CP / M-80. Assembler, he is an assembler, what to take from him. The kit includes the assembler M80.COM itself, the linker L80.COM and the librarian LIB80.COM. There is no IDE or editor. The ZSID.COM debugger and the surprisingly suitable DASM.COM disassembler were also supplied on the diskette.
    • Borland Turbo Pascal . Version 3.02A. Without exaggeration, the best development tool for CP / M. It had an IDE with a screen editor - simple, but adequate enough, and the best of everything else was by head. The compilation speed was also impressive. In this Pascal, I trained a lot in my youth, even the Mandelbrot fractal drew with well, very ridiculous speed. Cons - a healthy 10-KB runtime and a small amount of memory remaining on the source code and executable program code when the IDE is loaded.
    • The C the BDS . I hardly know this. It seems like a regular old C, without an IDE and with a not-so-standard standard library.
    • Archivers . This good was only on disks with non-adapted software. Archivers were interesting - they worked as Unix: separately compression and separately packing in one file. Only in CP / M is the opposite. First, individual files were packed, during which the middle letter changed in their extension (the SQUEEZE.COM archiver changed it to Q, the faster and much better compression CRUNCH.COM changed to Z, and the coolest CRLZH.COM, which only had enough on the Quorum of memory for unpacking - on Y), and then the compressed files were combined into a .LBR archive using the LU.COM or NULU.COM utility. There were unzips for ARC, ARJ, and ZIP. Theoretically, there should have been at least an ARC archiver, but I have not seen this.

    Compatibility with games for the Spectrum


    For compatibility with Spectrum software in the CP / M Quorum there are two very interesting programs - BETA.COM and GAMMA.COM.

    BETA.COM is, in fact, a TR-DOS emulator. From the word Beta Disk Interface. On Quorum-128, TR-DOS is in ROM, and such an emulator is generally not needed, but on Quorum-64, TR-DOS will not exist without it. The emulator is loaded into the zero page of RAM - the one that can be imprinted instead of Spectrum ROM - and works like the most ordinary TR-DOS. Perhaps crooked in places. Although the TR-DOS built into the Quorum-128 is actually somewhat crooked, and many programs that require low-level disk access no longer refuse to work. It is sad.



    GAMMA.COM is a much more interesting invention. In fact, this is a special version of the CP / M Quorum for launching Spectrum games, called Gamma-DOS.



    Gamma-DOS, like BETA.COM, uses a trick with the lower 16 Kbytes of RAM, but instead of TR-DOS they are castrated by most I do not want CP / M. The font in it is standard Spectrum, a third of the screen is not used at all (to save memory - you need to save the remaining two-thirds somewhere for the time of access to Gamma-DOS), there are no user areas, the TPA area is cut to a few kilobytes - although simple CP / utilities M still start normally.

    After starting Gamma-DOS (which can be done both from CP / M, using the GAMMA.COM command, and booting from a diskette where Gamma-DOS is written to the system tracks instead of CP / M), you can exit to the Spectrum BASIC using the SOS command. After that, you can download any game from the tape recorder. After loading, by pressing the NMI key (Non-Masked Interrupt), the Z-80 will force the transition to address 0x0066 and cannot be ignored) control will be transferred to Gamma-DOS, after which the game can be saved with the SAVE command and then returned into it with the RET team. Games are saved in .SPC format - in fact, this is the same memory dump as in TR-DOS with a “magic button”, only compressed.

    A trick with NMI is possible thanks to the verification provided in the Spectrum ROM of the Quorum - it switches to the zero page of the RAM if it contains the JMP processor instruction at address 0x0066 - that is, in fact, the ROM checks if the RAM has a processor routine for NMI.

    Games in .SPC format can be launched from the command line, as well as regular .COM commands, but usually a shell like RUN.COM is used for this:



    And go! :)



    It is worth noting that in my memory Gamma-DOS did not work very stably and quite often when trying to save the game it gave out “BDOS ERR ON A: BAD SECTOR” on seemingly perfectly normal diskettes. So I often used not Gamma-DOS, but SCREEN - a shell with a pseudo-graphic interface (and limited image editing tools - hence the name), which works much faster and more stable than Gamma-DOS, and is more convenient to use. SCREEN even had its own API - for it there was a separate format for executable files, .EXE - but I could not find its description anywhere, nor did it describe how SCREEN was arranged. I suspect that somewhere in the bowels there was still Gamma-DOS.

    The biggest drawback of both Gamma-DOS and SCREEN was that they only supported Spectrum-48 programs. Toys for the Spectrum-128, and these, of course, were often the coolest toys, could only be launched from the TR-DOS Quorum-128. Alas and ah.

    The present


    The quorum, unfortunately, did not gain such fame as the epic Pentagon, Scorpio or Profi, and remained a small-town Yekaterinburg computer, most of whose users probably did not suspect that it had a drive and some kind of CP / M. Theoretically, there were models Quorum-256, Quorum-512 and even Quorum-1024, but to buy them was very nontrivial, if at all possible. Now no “Quorum Ltd.”, as far as I know, has long existed.

    The UnrealSpeccy emulator adapted for Quorum can be downloaded here: http://atmturbo.nedopc.com/emulator/kv_emul/unrl020q.zip , and the system disk image here: http://atmturbo.nedopc.com/others/kvorum/kv_cpm/kv_cpm .zip . Some software is also in this archive:http://atmturbo.nedopc.com/others/kvorum/kv_soft2/kv_soft2.zip (not an image, separate files), including the M80 assembler and the CP / M-80 programmer’s manual in Russian. Thanks to the person who posted it all; as far as I know, there are no other images of the Quorum floppy disks on the Web. Successful experiments :)

    Also popular now: