Close

A: Drive

A project log for Novasaur CP/M TTL Retrocomputer

Retrocomputer built from TTL logic running CP/M with no CPU or ALU

alastair-hewittAlastair Hewitt 11/18/2021 at 04:060 Comments

The A: drive has 63 tracks across 4 quadrants. Each quadrant has 8 sectors making up a total of 32 sectors per track. The record size is 128 bytes for a total of 252k bytes (63*32*128). The first 2k is used for the disk directory leaving 250k available for storage.

The decision was made a while ago to use a RAM disk and a detailed design was discussed earlier this year. It's taken about 6 months to develop the code and get it working (amongst other things). The net result is the initial version of the micro kernel weighing in at a whopping 160 bytes of 8080 machine code!

:20F000003A80E8B7C0ED06AF3CE607CA00F03281E8DD09B7C208F079FE04D205F0FE01DA45
:20F0200005F0CA2BF02190F0F240F02141003A81E8CD4CF07EB7CA05F0360023E52198F04A
:20F04000D5875F1600195E2356EBD1E9C6E8677887876FC97B0F0F0FE603F604C9CD54F012
:20F06000DD08B7CA05F0CD4CF036023A81E82377C305F0E16E3A81E8677DED0BDD07C30585
:20F08000F03A81E867CD54F06FED0BDD08C305F005F005F05DF081F005F005F073F005F077

This initial kernel supports two operations: GET to read a record from the drive, and PUT to write a record to the drive. The record is specified using the DE register to represent the track (D register) and sector (E register). The most significant 2 bits of the sector are used by the kernel to determine a quadrant. Each quadrant is assigned to one of 4 virtual CPUs, each with its own 64k of RAM. 

Each of the quadrant CPUs run a program to respond to commands from the kernel and read/write records from the memory it manages. The following code maps the track/sector in DE to the memory location:

    MOV     A,D     ;A=00TTTTTT
    CPI     63
    JNC     WAIT    ;SKIP TRACKS>62
    MOV     A,E     ;A=000QQSSS - 4 QUADS OF 8 SECTORS
    RRC             ;A=S000QQSS
    RRC             ;A=SS000QQS
    RRC             ;A=SSS000QQ
    ANI     0E0H    ;A=SSS00000 - CLEAR QUAD
    MOV     E,A
    XCHG            ;HL=00TTTTTTSSS00000
    DAD     H       ;HL=0TTTTTTSSS000000
    DAD     H       ;HL=TTTTTTSSS0000000
    INR     H       ;HL+0000000100000000
    PUSH    H       ;SAVE HL

The current software still boots to the monitor program, but the monitor can now set a break point and call the kernel code to allow records to be read and written to the A: drive. The next step is to add some kernel commands for console input and output and plumb everything through with a CP/M BIOS.

The assembler code for the operating system can be found here: https://github.com/ajhewitt/novasaur/tree/master/src/os

Discussions