Date: Wed, 23 Apr 2025 10:47:14 -0500 (CDT) Subject: Getting back on TRK00 Since recuperating from shoulder surgery means I can't do a lot of physical activity, for the last month or so I've been watching a LOT of stuff on the YouTube on our network-enabled TV. I ended up watching a number of retro-computing channels and it made me nostalgic. So, I managed to dig out the Davidge DSB-4000 that a friend gave me back in the mid-1990s and scratched out enough horizontal surface to set it up. The next several days were spent turning the house upside down trying to find the boot disks. The DSB-4000 is the machine for which I developed a BIOS extension to let CP/M use the RehDesign GIDE interface which sandwiches between the Z80 and its socket on the main board. It still needs to boot from floppy. When I found the disks, I was dismayed to discover that the 3.5-inch disks wouldn't boot and I had a "720K" 3.5-inch disk as drive A:. I had a 5.25-inch 80-track DD drive as B:. Swapping the drive-select settings to put the 5.25-inch disk at A:, the 5.25-inch media booted! Furthermore, the 3.5-inch disks still had intact data on them--just the system tracks had "faded". I was able to re-write them with the Davidge FDGEN utility and they now boot. I'm still sorting my way through the disks as some have different requirements and features. It's been 30 years since I messed with that stuff and I'm having to re- familiarize myself with nearly everything. ----- Date: Fri, 25 Apr 2025 22:17:19 -0500 (CDT) Subject: Re: Getting back on TRK00 So, I've been getting my retro-computing fix working towards getting the Davidge to boot from the hard disk. (Damnit! When using WordStar, I have 'vi' fingers; now using 'vi', I have WordStar fingers...) As a first step, I reworked my "IDEGEN" utility to correct a major oversight--I'd only ever written CCP+BDOS to the hard disk system tracks in the past. Now I have it writing the full system image (less boot sector). To test it, I'm trying to cram my IDE disk reading code into 128 bytes so the ROM will load it from floppy and it will load the system from the hard disk. You'd think that using a modern *NIX system and a graphical terminal would have no problem keeping up with a 9600 baud console, but you'd be wrong. Or rather it's not speed, it's the peculiarities of XTerm/URxvt/etc.'s "ANSI" emulation versus how a genuine Heath/Zenith H/Z-19 terminal in ANSI mode behaves. Paging/scrolling in WordStar is fraught with clutter from where the screen isn't updated. I might just have to dig out a proper terminal to save my sanity. Having to look up syntax for M80 and L80 and so forth. The M80 I have seems to have a problem with the "SET" pseudo-op. It complains about undefined symbols for anything that uses it. I worked around it with an extra symbol using "EQU" and a conditional expression. ----- Date: Sun, 27 Apr 2025 21:14:16 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 25 Apr 2025, John D. Baker wrote: > To test it, I'm trying to cram my IDE disk reading code into 128 bytes > so the ROM will load it from floppy and it will load the system from > the hard disk. Success! It's a mess of spaghetti code and there's no room for error handling, but it loads CP/M from the hard disk and jumps to the CBIOS (cold) boot entry. Then I realized that with some wily conditionals, the same source could assemble boot sectors for the hard disk itself, and a "chain loader" floppy boot sector (that loads/runs the hard disk boot sector). Also, conditionals for testing under a debugger. Once I had a notional boot sector for the hard disk, I needed to update my "IDEGEN" program to include writing the boot sector. While futzing around in the code, I thought I would try to make it a bit more robust and user-patchable, but not before breaking it so it wrote garbage to the disk. It took a while to get all that "state" back in my head, but I eventually got it working again. The Conner CP-342 disk I'm using operates as 5 heads, 17 sec/trk, and I forget how many cylinders, but the result is that I manage each head as a separate disk for 5 full 8MB volumes. Once I was able to restore a working system to the "disk" (head) I was using for testing, I verified the hard disk boot sector worked. Then I verified the floppy-disk chain loader; then both of them together. It worked just like I envisioned, so I changed "test" to "false" and reassembled them, patched them into copies of the system image file and IDEGEN'd the hard disk and FDGEN'd the floppy. Now, on power-up/reset the rom boots the floppy which boots the hard disk which boots CP/M. I still need the floppy disk to load the bios extension to operate the hard disk, so the next step is to extract the BIOS code from the loader program, patch it into the system image file, patch the IDEGEN program with the new length to write, and patch the boot sectors with the new number of sectors to read. As a next step, the loader code will verify the extension's presence and jump to the BIOS extension's cold boot routine. If the code isn't found, it'll check for space and load it as before. Once I can guarantee presence of the extension code in any boot scenario, the "loader" reduces to just jumping to the extension's cold boot routine. I don't have actual CBIOS source for this machine. The only such source file is just the skeleton CBIOS supplied by Digital Research. I started disassembling the BIOS I actually have way back when, but it still needs much commenting and study. Likewise, I have source for _a_ boot ROM, but not _the_ boot ROM the machine actually executes. I'd also started a disassembly of it as well (again, way back when), although I have a print-out of the actual ROM source on ancient fan-fold paper. ----- Date: Tue, 29 Apr 2025 16:20:06 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sun, 27 Apr 2025, John D. Baker wrote: > I still need the floppy disk to load the bios extension to operate the > hard disk, so the next step is to extract the BIOS code from the loader > program, patch it into the system image file, patch the IDEGEN program > with the new length to write, and patch the boot sectors with the new > number of sectors to read. Well, that didn't go as planned at all... I got the image file patched with the GIDE code (or so I thought) and got the IDEGEN utility set up to write the longer image (again, or so I thought). So I detoured into some utilities I wrote in C to dump a range of cylinders/head/sectors to verify the disk contents. It appeared that nothing was being written beyond the end of the first track. That led down a path of modifying my C utility to do more error checking and provide information, which led to having to remember how to use the Aztec C development tools (and how I structured the IDE support libraries 30 years ago). I did find a blatant error in the IDEGEN program where I was writing the same value to BOTH the Cylinder-Low AND the Cylinder-High registers. Fortunately, there were no active files in that part of the disk, and for the most part a competing error saved me from corrupting the disk... To make the IDE utility programs as generic as possible, I don't bother trying to know the disk layout in advance. So, I read or write until I get a "Sector ID Not Found" error and take the appropriate action. This strategy works fine for reading, but it seems at least for the Conner CP-342 if you try to write to an out-of-range cyl/hd/sec, nothing is written, even if subsequent writes are to valid addresses. So, I fell back on the strategy I used for the "geometry seeker" utility and emprically determined the number of sectors/track using the "ID not found" error result and saved the count for later comparison so I'd know when to switch cylinders. I was already doing this to count the number of heads so I could offer the user a choice of "disk" (head) to read or write, so it was mainly a matter of duplicating the code except for which "coordinate" I was probing. With IDEGEN suitably modified, I was able to write the larger OS image past the first track. (It just so happened that the standard CCP+BDOS+BIOS fits _exactly_ in the first track--16 sectors plus boot sector.) There are still some rough edges to deal with, however. The OS image file was another puzzle--I am failing at math or something. Based on where my self-loading BIOS extension loads versus where all the parts reside in memory after a MOVCPM, the address where I loaded the standalone version of the BIOS extension should have put it in the right place, but it was 512 bytes too high. I eventually got that sorted out (I think) and the boot sector now loads the larger system image from the hard disk (ID Not Found doesn't have an adverse affect on subsequent reads). Then I wrote a simple bootstrap program in DDT that jumps to the BIOS extension's cold boot routine. With it set as the stock system's "turn-key" command in the CCP, the ROM boots the floppy which boot the hard disk which boots CP/M which activates the hard disk extension and which then stuffs a new command into the CCP to run NZCOM. There are rough edges to smooth out and I'd like to automate some of the steps--especially patching the boot sectors for which "disk" (head) of the hard disk to read and the number of sectors to read. ----- Date: Thu, 1 May 2025 09:12:38 -0500 (CDT) Subject: Re: Getting back on TRK00 On Tue, 29 Apr 2025, John D. Baker wrote: > There are rough edges to smooth out and I'd like to automate some > of the steps--especially patching the boot sectors for which "disk" > (head) of the hard disk to read and the number of sectors to read. And they got a LOT rougher before they got smoother. I almost had a catastrophe because I failed to mount a scratch monkey. At some point in my IDEGEN (re)development cycle, I got logic or arithmetic wrong and instead of reading/writing all sectors of the reserved/system tracks, it instead wrote the system image spread out on Sector 01 of every track for the given head! It almost took my source code with it! Almost. It took some experimentation to remember which of the utilities I had was a sector editor. I got even luckier that some of my IDE utilities in C weren't damaged, so I was able to use them to repair the damage to the directory blocks. The main source and .BAK files were small enough to load into DDT and patch out garbled areas so that it could be handled in an editor or with PIP. The main source and the .BAK file were both damaged, but not in the same places, so I was able to extract 2 of 3 "patches" from the .BAK file with PIP and re-inserted them with WordStar (in non-document mode, of course). The last patch came from the .PRN file created by the assembler. I had to patch it to make it readable, but it was too large to be loaded into memory with DDT. Eventually, I re-discovered PATCH.COM and was able to find non-ASCII bytes in the file and patch them out so I could extract the third patch I needed to recreate my source code. Once I had the IDEGEN source reconstituted, I started adding debugging measures--mainly conditionally-assembled dummy code that simply prints the cylinder/head/sector numbers and buffer addresses where it is expected to operate. The weird bit is that as long as both Read and Write operations were both dummies, it printed exactly what I expected. When I put the Read operation back to being the real thing, it bombed. As long as I skipped reading the system tracks (which would hang the system, the dummy write function would show the same behavior that trashed my disk before. The sector number stayed fixed at 1 while the track and the buffer address increased without bound (wrapping as you would expect). Fortunately, being dummy code, it just printed what it would have done. When my read routine was dummy code, I couldn't empirically determine the number of heads or number of sectors/track, so I just initialized those variables to the known values for my hard disk and continued. And while writing the above sentence, I finally figured out what was going wrong... The code was behaving as if there were only 1 sector/track, so when it came time to increment the sector, it thought it'd run off the end of the track and incremented the track. (But then the "bumptrk" code should have aborted the operation when the track number exceeded that of the reserved tracks--more debugging to do...) The crux of the issue is that I got sloppy and forgot that when the read routine returns, "A" is set to 1 as that's the last value loaded to be written to the Sector Count register of the IDE drive. I mistakenly saved it as "hstspt" thinking it was still the last sector number I'd saved in memory. Loading the last "hstsec" value and saving that at "hstspt" fixed that. (There was also some question about 8-bit versus 16-bit load/store and arithmetic. When I worked at VMETRO, I bitched about Lars' sloppy programming doing 8-bit stores and then 16-bit loads w/masking to read it back. You can theoretically get away with that on a little-endian machine, but when I was porting the code to run in a big-endian system (PowerPC), that bit me hard. So I had to sift through the code and make sure the data access sizes agreed for both stores and loads.) Likewise with my code. Even though there's only a single 8-bit register for the sector number (and sector count) in an IDE drive, CP/M uses 16-bit values for these data so I do as well. I made sure to initialize them appropriately, but was "cheating" by only reading/writing the LSB in the SPT-counting code (and then ignoring the result as mentioned above). Changing to 16-bit load/store (which read/wrote the _actual_ result) fixed things. Now to figure out why "bumptrk" isn't detecting access beyond the number of reserved tracks... So, using WordStar as a programming editor is frustratingly slow and its screen managment plays havoc with urxvt. I have long had VEDIT (v1.33) and used to use it when programming, but I'd forgotten how I had it configured. I was pretty sure I made it mimic WordStar as much as possible, but I needed to remember its command-mode functions. I finally got the ladder and fetched the manual down from the box where I'd put all that stuff away. I got just enough re-familiarized so I could load/save/search and it has been such a relief to use--so much faster. ----- Date: Fri, 2 May 2025 19:38:32 -0500 (CDT) Subject: Re: Getting back on TRK00 On Thu, 1 May 2025, John D. Baker wrote: > Now to figure out why "bumptrk" isn't detecting access beyond the > number of reserved tracks... A large part of that was forgetting what was a symbol definition versus a label and what they represented. Instead of loading HL _with_ the number of reserved tracks, I loaded HL _from_ the number of reserved tracks; which, being 2, meant that the program had a number of system tracks equal to IOBYTE*256 + WBOOTE SHR 8--more than the number of cylinders on the disk. The other part was me overspecifying the problem. I was trying to keep actual sector counts when all I really needed to do was read or write the system tracks in their entirety (like the sample cold-start loader in the Digital Research documentation does). So I ripped it out. (It didn't help that I wasn't computing the remaining sectors until _after_ I'd already read the first one.) Once satisfied that it was doing the right thing, I set "test" to "false" and gave it a go. It seems to do the write(!) thing. So I turned my attention back to the boot sectors and discovered why my math wasn't math-ing. Actually, my math was correct, but I forgot about a crucial issue with IDE drives. If you give it an invalid sector address, the cycle still completes with data available, but the data is that of the most recently-read valid sector. I suppose one can check for the error before reading data, or one can not advance their local buffer address so the next read from a valid sector replaces the erroneous data. I opted for the latter strategy. It's even messier spaghetti code than before and does a lot of DE<->HL jiggery-pokery, but it doesn't use the stack and fits in 128 bytes with room to spare. Testing the new IDEGEN and bootsector showed that they worked, but when I turned off test mode for the bootsector, reassembled, and patched it into an image, the boot failed with floppy disk BIOS printing its sign- on message and then garbage. It seems that the OS image files I was using got corrupted in my previous blunder and that's what was written to the hard disk's system tracks. Fortunately, I have several good copies around, so I was able to start re-patching those to generate the bootloader image for the floppy and the full CBIOS+GIDE extension image for the hard disk. Once regenerated, it works a treat! Next up, regenerate the hard disk boot sector and the chain-loader boot sector. ----- Date: Sat, 3 May 2025 08:02:37 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 2 May 2025, John D. Baker wrote: > Next up, regenerate the hard disk boot sector and the chain-loader > boot sector. Since the boot code is actually identical aside from load address (and number of sectors to load), for the hard-disk boot sector, I padded it so the same 128-byte sector of actual code was in the same location relative to the OS image as the standard boot sector, my full-load sector and my chain-load sector. So, there are 3 sets of relative jumps with 126 bytes of padding at the start. Should it ever be possible to generate a fully-relocatable system, MOVCPM will be able to relocate the BIOS jump addresses. The only remaining puzzle is why my math isn't mathing. Computing the number of sectors to load comes up one short, so I've been patching that in manually when I load an OS image file (or after IDEGEN with PATCH). Of course, I have to patch the head/drive selection byte as well, so it's not a big deal, but it would be nice to have that properly pre-computed. The image in memory (less boot sector) begins at 0980h and ends at 2900h (for the stock BIOS) or at 32B0 with my GIDE extension patched in. For 512-byte host sectors this gives: For the stock BIOS 2900h - 980h = 1F80h 1F80h / 200h = 0Fh ;15 512-byte sectors 1F80h % 200h = 180h ;with this much left over for 10h or 16 sectors to load, which is correct. With my GIDE BIOS extension patched in: 32B0h - 980h = 2930h 2930h / 200h = 14h ; 14h or 20 full sectors 2930h % 200h = 130h ; with this much left over for a total of 15h or 21 host sectors, except that's 1 short. And I think I figured it out. On SECID_NF, I'm skipping the buffer advance, but I'm still decrementing the sector count. I need to rearrange so it resets the sector number and bumps the track number and just goes back for another read without decrementing the count.. ----- Date: Sat, 3 May 2025 08:26:07 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sat, 3 May 2025, John D. Baker wrote: > for a total of 15h or 21 host sectors, except that's 1 short. > > And I think I figured it out. On SECID_NF, I'm skipping the buffer > advance, but I'm still decrementing the sector count. I need to rearrange > so it resets the sector number and bumps the track number and just goes > back for another read without decrementing the count.. OK, that was an easy enough fix. Saves an extra byte and 17 clock cycles. Actually, it saves even more than that since instead of falling through a "jp z,ldadr", I branch directly to the code that restores the next transfer address which then branches to read another sector. And, best of all, it works and my math is mathing again. Naturally, relative branches wherever possible. If you don't care about bit tests being destructive, "and n" saves a clock cycle on a memory access versus an opcode fetch (for "bit n,r"). If the bit of interest is 7 or 0, rla/rra to push the bit into the Carry flag is only the one opcode fetch. I should extract all the duplicated stuff into appropriate macro libraries and refactor the code... ----- Date: Mon, 5 May 2025 15:22:25 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sat, 3 May 2025, John D. Baker wrote: > I should extract all the duplicated stuff into appropriate macro > libraries and refactor the code... But instead, I dug out the printouts of the boot ROM source code and its associated assembler listing (.PRN) and have been typing away transforming the disassembly I started back in 1996 back into the source code on disk (I never had the actual source--only the printouts). I've attempted to make a faithful recreaton, including spelling/typographical errors, spacing, code style (lots of lowercase interspersed with all uppercase, etc.) In so doing, I discovered that the ROM in my board differs from the source listing by 2 bytes--the receiver mode byte for each of the first two serial ports. The listing shows "3,0E1H" which enables the receiver and sets it for 8 data bits as well as "auto-enable" which means DCD* must be asserted for the receiver to work and CTS* must be asserted for the transmitter to work. My machine's ROM has "3,0C1H", which omits the "auto-enable" bit, which I gather means the transmitter and receiver are active all the time. (I'm using an old Toshiba TLCS Z-80 databook and it has the usual translation challenges). So, I've made two versions. One that matches the printout and the other that matches my actual ROM image. A third copy I'm editing to use the macro definition libraries as well as appropriate local definitions instead of "magic numbers". I also intend to fix spelling/typographical/style issues and reformat block comments and long strings to be "email friendly" (72 columns or less). Perhaps then I'll compare it to the "4000ROM.ASM" file I have which seems to have been for later revision boards and included support for a couple of different SASI controllers that could be connected with an adapter interface (I even designed one myself some time back--if I can find my schematic I might try putting it in KiCAD...) But really, I hope to see how they managed to squeeze SASI support into an already packed 2K ROM. Then I could see about putting (G)IDE support in its place. ----- Date: Fri, 9 May 2025 03:51:37 -0500 (CDT) Subject: Re: Getting back on TRK00 On Mon, 5 May 2025, John D. Baker wrote: > But really, I hope to see how they managed to squeeze SASI support into > an already packed 2K ROM. Then I could see about putting (G)IDE support > in its place. The main thing they did was reduce the size of a number of character strings. A couple of functions that previously output a fixed sequence of characters one-by-one were changed to simply set up pointer to a string with that sequence and call (or fall through to) the string display routine. The convention that any carriage-return (0Dh) encountered in a string will always be accompanied by a line feed (0Ah) previously enforced CR,LF. For purposes of display it doesn't matter which comes first, so changing it to display LF before CR made the code simpler and shorter. The routine reading the serial port now does explicit "toupper()". I need to see if the longer input routine is offset by savings in other places. Another thing is one-time initialization code. The Davidge board maps ROM as read-only and RAM as write-only on power-up/RESET. So the first thing the ROM does is copy itself over itself so it is in RAM then switches off the ROM. For whatever reason, they chose to use 0080h as the buffer for reading the boot sector from a floppy disk. Since this is inside the area occupied by the (ex-)ROM code, the part from 80h-FFh will be overwritten with sector data. They didn't go far enough with putting single-use items in the floppy sector buffer; the entirety of the initializtion code and initial message, less a relative branch fits in the buffer with room to spare. That leaves a significant portion of the space from 00h-80h available for code and data. So, I've been grafting changes from the 4000ROM.ASM file to my heavily edited version of the "D3115" ROM image. I managed to get enough space to add in my code to load the hard disk boot sector. It was basically my chain-loading floppy-disk boot sector, but cut down even more, since it only ever has to read Sector 1 on Cylinder 0 of whatever "disk" (head) it is trying next (I abuse the ROM's retry mechanism to cycle heads and reset to 0 if an error is returned from the IDE disk). Concerned about getting stuck if the drive doesn't respond, I augmented my "WaitRdy" and "WaitDrq" routines to indicate an error if the respective bits in the status register don't indicate the desired result after 65536 tests. In the process, I learned that coding the countdown in each function was actually shorter than making it a subroutine. For testing, I substitute code of the same length that replaces jumps or calls to potentially hazardous stuff--namely the floppy-disk routines. Puzzling that the initial message display never happens. I jump over the code that initializes the I/O ports since the BIOS is already running, but any code that uses the right addresses should still be able to operate the SIOs directly. But the messages never appear. But my "ideload:" routine does sucessfully read the boot sector from the hard disk. ----- Date: Fri, 9 May 2025 21:32:03 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 9 May 2025, John D. Baker wrote: > The routine reading the serial port now does explicit "toupper()". I > need to see if the longer input routine is offset by savings in other > places. Doing "toupper()" (ANI 5Fh) on lowercase letters adds 13 bytes to "CHRIN:" but saves 8 bytes in "ASCHEX" and another 2 bytes in the test for a command character. So, net 3 bytes longer code. I finally got a chance to read in more detail some things added and changed. In particular, the Monitor entry point pushes its own start address on the stack and the various command functions were changed from spaghetti-code jumps/branches to RET back to the start of the monitor, or if their last operation was to use one of the other utility routines to jump/branch to it and when the utility routine returned, it started at the top of the monitor again. So it abuses the stack horribly as error exits simply jump to the error routine which jumps back to the call to display the error message which then re-enters the monitor proper, pushing its start address again. It makes me cringe, but being bootstrap ROM code, it can probably get away with this as it shouldn't be running long enough for the stack to grow all the way from the top of RAM to overwrite the bootROM code. In so doing they save a byte (JR) or two (JMP) here and there, so I suppose it adds up. Looking at it further, I think a single 1-byte instruction will keep stack operations balanced. The ERROR routine simply needs to pop the top of the stack before jumping back to before the beginning. Also, they duplicated an error exit which when eliminated will save another 3 bytes. Their ASCHEXB, ASCHEXW routines seemed fairly straighforward, but in the 4000ROM, I guess they realized they only ever use the ASCHEXB routine internally, so made it an extension of the ASCHEXW routine, but changed the input parameters to ASCHEXW by requiring HL to point to the byte _before_ the string to convert. It would only cost symbol table space to keep it "clean". ----- Date: Sun, 18 May 2025 12:56:38 -0500 (CDT) Subject: Re: Getting back on TRK00 So, having a boot ROM that can load a boot sector from an IDE drive is still not much use if the hard disk support still needs a program on floppy disk to activate it since its still entirely independent of the stock BIOS until its HBOOT routine is executed. So lately I've returned to analyzing and commenting the disassembly of the stock FD-4000 v1.3 BIOS so I can eventually integrate my IDE support. There are still a few functions and data areas to demystify, but I figured out enough to patch my GIDE extension to use the stock BIOS's message-display routine (hi-bit last character as terminator) and how to chain the extension's HBOOT routine to the floppy BIOS's stock BOOT routine. It's almost as good as a fully-integrated system. At some point I want to make that more automagic. In particular, reduce the image size by putting the extension BIOS and a small loader routine right at the end of the BIOS image and chaining to the loader which moves the code into place then jumps to HBOOT. Now that I think about it, I can't get it _too_ close to the end unless it can fit entirely in the host buffer space, or can't be placed closer than some of flag locations initialized by the final stage of the (W)BOOT routines. If my src/dest overlap, I'll have to see about moving code from the end rather than the beginning. ----- Date: Tue, 20 May 2025 08:42:12 -0500 (CDT) Subject: Re: Getting back on TRK00 I learned enough to be able to use the stock CBIOS' message-printing routines and where to patch my loader address so the stock CBIOS will run it instead of RETurning to the CCP. The loader routine and all of what used to be the BIOS extension's BOOT: routine fit easily in the space between the end of the stock CBIOS code and the data area initialized by it. The loader tests whether the destination address overlaps the code/data block to move and, if so, uses "LDDR" to move the code from back to front. As such, the BIOS extension's BOOT entry point is simply the same as WBOOT and there is no more code related to cold boot operations in the BIOS extension itself. It's as close to integration as I've come so far. I don't even need the turnkey command patch anymore, but I've left the code in and improved it so it's easy to skip if not needed. If I can burn a boot ROM, it should boot and run entirely from the hard disk. ----- Date: Tue, 20 May 2025 19:37:11 -0500 (CDT) Subject: CP/M development tools In other news: microsoft M80 is weird--at least the copy I have. It chokes on the 'SET' pseudo-op, claiming undefined symbol for anything I try to use it with. More recently, it has trouble with the MOD (modulus) operator in some contexts. Usually it works as expected, but sometimes it does something undesirable. In a few places, I want to pad the address to the next 8 or 16-byte boundary so things line up "right" when looking at them with DDT(Z) or some other file hex-dump utility, or to make it easy to find things if one must resort to patching the binary. My typical idiom is: defs 16 - $ mod 16 or defs 8 - $ mod 8 This works without issue in ASM or MAC ('ds' instead of 'defs'), but in M80, it _sometimes_ works, but mostly doesn't--it pads up to the desired boundary but then adds an additional 8 or 16 bytes besides. To get around this, I've taken to using: defs 16 - $ and (16-1) or defs 8 - $ and (8-1) So far, this has been Doing the Right Thing(tm). ----- Date: Wed, 21 May 2025 09:44:34 -0500 (CDT) Subject: Re: Getting back on TRK00 On Tue, 20 May 2025, John D. Baker wrote: > If I can burn a boot ROM, it should boot and run entirely from the > hard disk. I went back and looked at my modified "D3115" ROM source, the original, and the 4000ROM source just to be sure I didn't overlook something. My first concern was to make sure the CTC interrupt vectors fell on an 8- byte boundary, which they did. The original D3115 ROM source seemed to have arbitrarily put the CTC vectors beginning at 0048H (actually, it puts scratch space for a FDC "READ ID" command and a couple of extra result bytes at 0040H, EQUates "CTC0V" with the current location ($), computes the vectors for CTC channels 1, 2, and 3 then issues an ORG CTC3V DW CTCISR The 4000ROM code explicitly puts the CTC interrupt vectors at 0058H with a comment of "; must remain at this location" and defines a dummy ISR for channels 0-2. I went back and looked at my disassembly of the boot sector for a 64K CP/M system and saw what was going on. The ROM code itself doesn't use DMAC interrupts, only FDC interrupts via CTC3 (CTC0 ch 3), but the boot sector DOES use DMAC interrupts and sets up the DMAC interrupt vector at 0058H. In the stock D3115 ROM, this just trashes the ROM's DMA init string, but at that point it doesn't matter. The 4000ROM code, which supports booting from SASI, makes a point to put the CTC intvecs where the floppy boot sector won't damage anything (CTC0 ch 0-2 are programmed not to interupt, so the CTC00 vector can be used by the DMAC). So, I adjusted my modified D3115 ROM code to match the 4000ROM layout for the CTC vectors and rearranged some data items to fill the space between the end of the vectors and 0080h (where 1-time init code and messages live until overwritten by the floppy boot sector). There's 49 bytes of space left in that part of the ROM, and another 144+ in the part above the floppy boot sector buffer. I'd like to be able to use the DMAC for IDE data transfer. I could probably do it in the ROM code since I only have to transfer one sector. The FDC (and "high-speed parallel port"--for the SASI host adapter) can signal the DMAC in "byte-at-a-time" mode using its RDY signal (DRQ from FDC, [DATA & RQ] from SASI). The GIDE doesn't have such a connection, so I'd have to use the DMAC burst mode. In the boot rom and boot sector, I have some control over the DMAC operations, but in the BIOS itself, the DMAC interrupt vector(s) are under control of the CBIOS. I might be able to patch the ISR address and dispatch to the CBIOS DMACISR or the extension's DMACISR as necessary. I need to go back and look at the DMACISR to see just what it does. If all it does it operate the DMAC itself, it's probably harmless to use as-is and I just have to whip up my own DMAC init string. ----- Date: Wed, 21 May 2025 13:05:06 -0500 (CDT) Subject: Re: Getting back on TRK00 A friend commented: > I did not know the CTC interrupt vectors had to be on an 8 byte boundary. There are 4 channels in the CTC, so each channel can have an independent ISR. In the vector byte it supplies during the IACK cycle, bits 7-3 are the previously-programmed vector base address, bits 2,1 are set according to which channel (0-3) interrupted and bit 0 is always 0. Since CTC channel 3 has no ZC/TO pin, it is commonly used to allow arbitary LSI--the FDC or the SASI host adapter in this case--to participate in Z80 mode-2 vectored interrupts. The other channels are typically used as clock dividers/baud-rate generators for the SIO devices. The DMAC's interrupt vector can be anything and need not be aligned unless using the "status affects vector" feature where it will alter 2 bits (I forget which ones offhand) to provide a different vector address for each of 4 conditions. ----- Date: Thu, 22 May 2025 20:40:23 -0500 (CDT) Subject: Re: Getting back on TRK00 On Wed, 21 May 2025, John D. Baker wrote: > I'd like to be able to use the DMAC for IDE data transfer. I've revisited the ROM's operation of the FDC and DMAC and the stock boot sector's operation as well. In the ROM, only the FDC interrupts and its ISR just reads its own status port and stores it in a location that gets polled by the read routine. The DMAC is operated w/o interrupts and just transfers the requested length of data. After starting the DMAC, the ROM code sets up the FDC, conditions the status location, starts the FDC and sits in a tight loop polling the status location to determine when the FDC is finished. Since the DMAC only transfers data when it's RDY* input is asserted, it doesn't request the bus until the FDC signals it. The boot sector does something similar, but operates the DMAC with interrupts. Similarly (yet differently) to the ROM, the boot sector sets up the DMAC, sets up and starts the FDC and halts (instead of polling). When the FDC interrupts, the boot sector code resumes, checks status and if good, sets up the next sector to read in the FDC, starts it and halts again. Repeat until the block length programmed into the DMAC has been transferred. The DMAC ISR doesn't RETI--it reset the DMAC, stops the FDC and jumps to the BIOS BOOT entry point. I could probably use something similar to what the ROM and boot sector do with the FDC and DMAC, but using burst mode with the DMAC's internal RDY* signal. Basically, that makes it appear RDY* is always asserted, so as soon as the DMAC is started, it will transfer data in back-to-back read-write cycles until the byte count is exhausted. Once the DMAC acquires the bus in burst mode, it will not relinquish it until it is finished, so polling for status wouldn't work. So far, halting seems the most reasonable thing to do while waiting for a DMAC interrupt. Like the floppy boot sector, I could arrange to read multiple sectors from the IDE disk, although I wouldn't be able to handle SECID_NF errors after the fact--I'd have to know up front how many sectors I can read before bumping to the next track. Actually, I don't know what an IDE disk will do when you request more than 1 sector to read and the count overflows a track. I presume it continue with sector 1 on the next head of the same cylinder and only when the last sector on the last head of a cylinder is read will it go to the next cylinder. Since I manage each head as a separate "drive", I can only read sectors 2-n on track (cylinder) 0 and sectors 1-x on track (cylinder) 1. Sounds like time to hack up my utilities to experiment with multiple- sector transfers. As for the FD-4000 v1.3 BIOS, the DMAC ISR simply issues a reset command to the DMAC and the FDC ISR simply re-enables interrupts and does an RETI. I've figured out the BIOS' scheme for all the different floppy formats it supports and have been replacing fixed addresses with labels in my reconstructed source. Starting to wrap my head around some of the ancillary things involved, but need to ruminate on them a bit more. Figuring out the layout/ordering of the disk deblocking variables is being ironically difficult considering that it was my analysis of the FD-4000 BIOS 30 years ago that aided the development of my original GIDE extension. There was some clever ordering to the SEK/HST/UNA- DSK/TRK/SEC variables that made it easy to do block transfers for setup and a clever "STRNCMP" function rather than discrete loads/stores or comparisons. It isn't quite as clear today. ----- Date: Sat, 24 May 2025 05:49:35 -0500 (CDT) Subject: Re: Getting back on TRK00 So, I started playing around with my chain-loading boot sector to see if I could use the DMAC to load the HD boot sector. The Z80 DMAC documentation didn't say explicitly that the "forced RDY" couldn't be used with "byte mode" although it only referred to burst and continuous mode when discussing the forced RDY command. There's also no real description of what happens if the setup string programs contradictory options. From what I could see, the DMAC simply doesn't start. Switching the DMAC to burst mode with forced RDY seemed to work. Although in this arrangement the DMAC will only reliquish the bus at the end of the transfer, I used a polling loop that tests for the DRQ bit in the IDE status register to be 0 (previously waited for it to be 1 before starting the DMA). It seems to work. Then, out of paranoia, I augmented my polling loops with retry counters and error checks and it stopped working. I thought I'd screwed up the DMA string due to trying to make debug/non-debug code the same size in the same locations. Then, actually re-reading what I'd copy-pasta'd, I found a missed edit that sent a polling loop back to the wrong label (the loop i'd copied the code from). After fixing that, it worked again. I couldn't use DMA interrupts while debugging, so I'll have to live test that, but I basically copied what the stock boot sector does (except for handling the FDC). But I now see how to use the DMAC to load the HD boot sector from my custom ROM (if I ever get around to burning it). Probably experiment with multiple-sector IDE transfers next as that will be key to using DMA in the HD boot sector itself. ----- Date: Sun, 25 May 2025 15:47:38 -0500 (CDT) Subject: Re: Getting back on TRK00 I thought I could hack a way to use DMA interrupts while debugging by plugging in the known IVL byte the BIOS uses since it just resets the DMA and RETI. I was able to trace operation up to the HALT instruction, then nothing. My guess is that as soon as I enabled the DMAC, it acquired the bus, transferred the data, interrupted and the ISR ran all before my HALT instruction was ever fetched. So, it's sitting halted with nothing to wake it up. So, unlikely to be able to use DMAC interrupts with the IDE disk. As long as I do my little polling loop, it seems to work. Re-reading some of the IDE interfacing articles that got me involved with this project in the first place, I realized I should always check the BSY bit of the status register before anything else, then check the ERR bit and, if set, handle that before anything else. Even if you told the drive to read a non-existent sector and the drive still sets DRQ, check the ERR bit before anything else. You are under no obligation to read any data available if an error is indicated. Non-destructive bit tests FTW. I made this change to the HD boot sector I wrote and it eliminates having to save the current xfer address since the data from the bogus read is never actually transferred. When experimenting with my chain-loader boot sector for the floppy, I realized there was only one byte of variable data needed, so I made sure to locate it as the very last byte of the sector. The idea is to tell the hard disk boot sector which "disk" (head) it was loaded from so it will load the system from the same one. My nascent boot ROM does the same (although it will need to be updated to the new scheme). The floppy and HD full-loader boot sectors need 3 additional bytes of variables, so they now come before the "disk"/head variable. I was thinking about multi-sector reads (Sector Count register >1), but I'm not sure I can use them since the disk pauses between each sector to do the BSY/DRQ dance rather than just transfer n*512 bytes directly. I think that might be what the {READ,WRITE}_MULTI commands do, but I don't have much documentation on those. So then I started playing around with loading the system from the hard disk using the DMAC. A key feature is the "Continue DMA" command. After initial setup, the address counters remain at whatever the next tranfer address is so one only needs issue the "Continue" command, load a new byte count and any other options (like forced RDY) and start the DMA. This overflowed 128 bytes, but it's for the hard disk boot sector, so that's OK. It seems to work great in testing, but something's not right when I try to use it for real. I get the FD-4000's sign-on, then the GIDE extension's sign-on, but then it looks like the monitor prompt displayed on the terminal. Something is reading characters and responding, but I don't know what it is. ----- Date: Mon, 26 May 2025 08:02:11 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sun, 25 May 2025, John D. Baker wrote: > So then I started playing around with loading the system from the hard > disk using the DMAC. A key feature is the "Continue DMA" command. > [...] > It seems to work great in testing, but something's not right > when I try to use it for real. I get the FD-4000's sign-on, then the > GIDE extension's sign-on, but then it looks like the monitor prompt > displayed on the terminal. Something is reading characters and responding, > but I don't know what it is. So that brings up another possibilty. After loading the system instead of jumping to BOOT:, deliberately jump to the Monitor since it's still in memory and unmolested at this point. I went back to my binary image of the D3115 ROM to find the entry point (I should check that my re-creation of the D3115 source matches--my custom ROM, if I ever get around to burning it, will have a different entry point). ----- Date: Mon, 26 May 2025 08:19:25 -0500 (CDT) Subject: Re: Getting back on TRK00 A friend asked: > I would be interested to know how much time your "little polling loop" > takes up. > I know that you write good software, but I have seen some really crappy > ones come out of Micro$oft. Considering what I've seen in testing, nearly 0. Once I start the DMAC, it grabs the bus and everything happens before the next instruction fetch. Back when I had retry counters on it, they never decremented unless something went wrong with the DMA operation. ;Before writing to IDE registers: iWtRdy: in a,(iRgStat) ;get status rlc ;BSY bit to Cy jr c,iWtRdy ;brif still busy ;After writing the command byte to the IDE Cmd register: iWtDrq: in a,(iRgStat) ;get status bit 7,a jr nz,iWtDrq ;brif still busy bit 0,a jr z,chkDrq ;brif no error if chain jr cold ;start over if error else jr chknf ;see if it's one we handle endif chkDrq: and 8 jr z,iWtDrq ;brif no data yet ;After starting the DMAC: iWtDma: in a,(iRgStat) bit 7,a jr nz,iWtDma bit 0,a jr z,chkDone ;brif no error jr cold ;else start over chkDone: and 8 jr nz,iWtDma ;brif data unread ----- Date: Wed, 28 May 2025 10:58:26 -0500 (CDT) Subject: Re: Getting back on TRK00 So, email has resumed working. (At least the POP3S part has. This will be a test of whether the SMTP part is working.) On Mon, 26 May 2025, John D. Baker wrote: > So that brings up another possibilty. After loading the system instead > of jumping to BOOT:, deliberately jump to the Monitor since it's still > in memory and unmolested at this point. I went back to my binary image > of the D3115 ROM to find the entry point. So, I did just that. Nothing looked amiss, but G produced the same result. So combining my Block I/O boot sector and my DMA boot sector into one test program and using the STRNCMP function I learned from the FD-4000 BIOS, I discovered that the DMA boot sector is dropping a byte. It's at a weird place, too You'd expect it maybe at a sector boundary, but it's 136 bytes into a sector. Also, it's the second sector of track (cylinder) 1, when I'd expect trouble between the track0->track1 switch. The handling of the IDE disk is identical in each case. Wait for not BSY, set up the cyl/hd/sec, sector count and send the command. Then wait for not BSY, check for error (if error, handle it and start over) wait for data. The data read operation is the only thing that differs. For Block I/O, just a pair of INIR instructions reads 512 bytes. For DMA, an OUTI instruction sends the ENABLE DMA command to the DMAC. After the DMA, the IDE status register is again polled to make sure the data have all been read. Then the sector number is incremented, the count is decremented--in the case of DMA, the CONTINUE command is sent--and the read operation is repeated until the sector count reaches 0. There are some refinements I can make now that I've been able to read a Z80 peripherals manual that doesn't have translation challenges. (instead it has OCR challenges). ----- Date: Wed, 28 May 2025 22:12:53 -0500 (CDT) Subject: Re: Getting back on TRK00 A friend asked: > OCR challenges? Really? Hmm. Maybe not. Maybe just typographical errors reading from a poor original. At one place in the DMAC section of the Z80-Family peripherals user manual, what should have been "DMA" is printed as "DIVA". In a diagram showing the hierarchy of WR4, bits 2,1 of the IVL byte can change with the "Status Affects Vector" option, but all bit combinations are shown as "0 0". This is in the copy I just downloaded directly from Zilog.com. I did learn that to use the "Continue DMA" command one does not have to load a new byte count. There's a difference between the transfer length one programs and the actual byte counter. The byte counter starts at 0 and counts up until it reaches the value programmed via the init string. The Continue DMA command clears the counter back to 0, which is exactly what is needed. The Forced RDY is disabled on various conditions including end-of-block and when the DMAC releases the bus, so of course one must include it in the command stream to use the Continue DMA function. ----- Date: Fri, 30 May 2025 11:02:47 -0500 (CDT) Subject: Re: Getting back on TRK00 On Wed, 28 May 2025, John D. Baker wrote: > So combining my Block I/O boot sector and my DMA boot sector into one > test program and using the STRNCMP function I learned from the FD-4000 > BIOS, I discovered that the DMA boot sector is dropping a byte. It's > at a weird place, too You'd expect it maybe at a sector boundary, but > it's 136 bytes into a sector. Also, it's the second sector of track > (cylinder) 1, when I'd expect trouble between the track0->track1 switch. Even weirder is that less than a sector later, it's back in sync and the rest of the data compare exactly. > There are some refinements I can make now that I've been able to read > a Z80 peripherals manual that doesn't have translation challenges. I misunderstood the difference between the user-accessible registers versus the internal registers the DMAC uses during operation. That the "Continue DMA" command clears the Byte Count Register to 0 doesn't mean one must load a new byte count. The Byte Count Register always starts at 0 and increments and is compared to the tranfer length that was programmed. So, that's 3 bytes I don't need to send (WR0 base register word + 2 bytes of length). Nothing I did made things better--in fact everything I've tried so far seemed only to make the data loss occur earlier in the stream. So, I've been looking back at IDE interface documentation to see if there's something there that might help. So far, the only thing I've played with is using the Read Verify Sectors command (40h, 41h w/o retries) for doing head/sector/cylinder counting instead of a standard Read Sectors (20h, 21h w/o retries) since the Read Verify Sectors command guarantees no data transfer. So, I've gone through another round of debugging, first loading A _from_ 0040h instead of loading A _with_ 40h, then twisting my READY, DRQ, STATUS and ERROR routines around to make them more robust but breaking them first and trying to figure out why it's off in the weeds. Realizing that if one is interested in an error condition one must read the ERROR register to clear it even if you don't care what the exact error is. I think I have the IDEGEN program back in working order--still running in test mode for now (reads are real but writes are simulated). ----- Date: Fri, 30 May 2025 18:50:18 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 30 May 2025, John D. Baker wrote: > of loading A _with_ 40h, then twisting my READY, DRQ, STATUS and ERROR > routines around to make them more robust but breaking them first and > trying to figure out why it's off in the weeds. Realizing that if one One thing I realized is that the strategy for the ROM code is not really appropriate for the IDEGEN utility. In the ROM code, any error condition is grounds to abort the entire attempt, so my status routines check everything, looking for an error condition. In the IDEGEN utility, when we're counting heads or sec/trk, an error is expected, but only one particular error (SECID_NF)--any other is outside the scope of what we can handle. I at first had put in my Swiss-Army-Status-Routines, but then realized I needed to differentiate between different types of failure. I've made some progress there, but I'm still pondering how to approach the issues. First and foremost, Wait for Not BSY (iWtRdy) is key to everything. Until the BSY bit the in status register is reset, the most recent command written to the Command Register is not finished, no other register contents can be considered valid, and the Task File registers must not be written to. The examples I cribbed my original implementation from simply looped until the bit was reset. Paranoid about entering an endless loop, I wrapped a counter routine around polling the BSY bit but I'm still pondering what it means for the routine to return a result meaning the drive is still busy and what the caller should do when it gets that result. Even more troublesome is when the caller is a fairly low-level routine (the one that sets up the Task File registers for the next operation). Maybe that's the answer--only call iWtRdy from a routine that will actually be sending a command byte. Then, the low-level setup routine doesn't have to and the upper-level routine handles the case of the drive still being busy. That's likely the answer to the other status routines (iWtDrq, iChkErr, iErrTyp) as well. Don't check the BSY bit yourself, if the upper level routine determines it needs your services, it will have done that before calling you. Also, an issue of unifying the results of status routines that return a error/no-error result. In the past, I simply used whatever mechanism was most convenient--rotate a bit to the Carry flag or AND with a mask of the bit of interest, so you had to know how error/no-error was indicated depending on which status routine you used. With the introduction of the counters around polling BSY (and DRQ), I've since implemented a Bourne-shell-like mechanism where the routine returns A=0,Z=1 for no error and A=FF,Z=0 for error. (Now that I think about it, I believe routines like CP/M CONST do the opposite--actually, I need to look at the CBIOS source reconstruction to see how they do their status routines. It would be good to have consistent style.) It helps to talk (write) these things out. ----- Date: Tue, 10 Jun 2025 22:09:50 -0500 (CDT) Subject: Re: Getting back on TRK00 I've been assembling my sources with microsoft M80 using Zilog mnemonics (".Z80" pseudo-op). It appears that while one may freely mix intel-style and Zilog-style pseudo-ops in either 8080 or Z80 mode, Z80 mode _requires_ using the Zilog-style "DEFL" rather than intel-style "SET". Having discovered that, I've been updating my boot-sector sources accordingly. A subtle rearrangement of data areas in my boot sector code saves an instruction and makes the boot sector more easily patchable for the number of sectors to load as well as from which "disk" (head) of the hard disk the system should be loaded. The disk/head is always the last byte as it is present in all forms of my boot sector and the number of sectors is just before it in the non-chain-loading boot sectors. This way, the IDEGEN utility can patch the number of sectors according to the number of records read from a system image file. I've decided that using the DMAC with the GIDE is not reliable enough. Perhaps in a more sophisticated implementation where the various other interface signals (INTRQ, DMARQ/DMAACK, etc) can be incorporated, the DMAC could be used, but that's not the GIDE. It only sees the world through the pins on the Z80 CPU. I've been making a few improvements to my (G)IDE ID program. I think the Conner CP-342 must predate even ATA-1 as its ID record has nothing after the model string. So far, I can parse the Configuration Word among other basic data. Re-learning the behavior of unions in C along the way. I also re-wrote my (G)IDE Geometry Seeker that empirically determines the number of heads, sectors/track, and cylinders a disk has. It uses the Read Verify Sectors command so there's never any data transfer. It prints more progress information (a '.' for every head, every sector, and every 32 cylinders scanned). When I say re-wrote, I basically typed it all in again as I don't have the source code for it on any of the disks I have. (It might be on one of the 8-inch floppies, but I don't have 8-inch drives attached right now and don't have space for them anyway.) The source only exist(ed) on an archive copy of my old web pages back when I had access to a public-facing web server. While I can play tricks with 'cu's "~<" and 'pip con:=foo' to send text from the DSB-4/6 to the UNIX host, going the other way was just too fast for the Davidge to keep up, so I hand- transcribed it all. I've since written a 'pace' utility that simply reads from STDIN and writes to STDOUT sleeping 1ms (really 10ms due to NetBSD tick frequency) between characters and an additional 1(0)ms after a newline. I haven't had a chance to try it yet, though. ----- Date: Wed, 11 Jun 2025 07:58:57 -0500 (CDT) Subject: Re: Getting back on TRK00 I stepped away for a while to think after having some disturbing run-ins with the 'SAVE' utility (writes 'n' pages starting at 0100H to the named disk file). Sometimes it would pre-pend an extra record (128 bytes) and lately, it caused a broken directory entry to be written to disk. In the stock CCP and standalone replacements like ZCPR, 'SAVE' is a resident (built-in) command. Under the NZ-COM arrangement, 'SAVE' is an external utility that relocates itself and runs at the top of the TPA so that it won't(!) clobber the image it's supposed to save. I may just have to dump NZ-COM for stock CP/M (and ZCPR w/resident SAVE) before SAVEing any memory images (patching w/DDTZ or extracting system images from the reserved tracks). Finally reading "The SCSI Bus and the IDE interface" that I bought decades ago. I put union{}foo; around elements of the ATA ID record that changed meaning between ATA-1 and ATA-2 (ATA-3 was still just a proposal at the time the book was written). Then, I had to access a union member in my ID reading/parsing utility. ----- Date: Thu, 12 Jun 2025 09:40:09 -0500 (CDT) Subject: Re: Getting back on TRK00 On Tue, 10 Jun 2025, John D. Baker wrote: > I've since written a 'pace' utility that simply reads from STDIN and > writes to STDOUT sleeping 1ms (really 10ms due to NetBSD tick frequency) > between characters and an additional 1(0)ms after a newline. I haven't > had a chance to try it yet, though. So, I tried it and it's useless because the terminal has an output buffer that only gets written when a newline appears, so I may be delaying between each character I send, but the buffer is written at full speed, so I still lose characters. At least putting the tty into "raw" mode disables "imaxbel" which inserts Ctrl-G into the data stream if I still manage to overflow the buffer. So I had to re-learn how I patched 'ZMP', a smart terminal program that supports Z-Modem transfers. Looking at it with DDTZ, I saw that I had hacked it to reserve a 256-byte fifo at the top of TPA (and created an extra level of BDOS entry indirection so ZMP wouldn't wipe it out with its own memory-sizing routine. It also does interrupt-driven receive and RTS/CTS handshaking. (I also patched the command-escape character from ESC (0x1b) to FS (0x1c) so it would operate the same way as QTERM. Still use ESC to abort a protocol transfer, however.) The first hurdle was a null-modem cable that implemented RTS/CTS. I use a lot of 4-wire phone cord for simple serial connections with DE-9 and DB-25 RJ-11 adapters and I have a lot of 6P6C RJ-11 ends. So I went to my pile of de-commissioned ethernet patch cords (those rated less than Cat5e) and found one of suitable length to make a 6-wire phone patch cord (what Cizzcoee would call a "rollover cable"). The DE-9/DB-25 RJ11 adapters all loop DTR back onto DCD and DSR, and are otherwise wired identically, so a plain patch cord of 4 wires forms a null modem and 6 wires adds RTS/CTS handshaking. After a number of false starts (and subsequent reset cycles), I got it working enough to log in to the *NIX system on its other serial port. I could have sworn I got better performance out of it when using a high-speed modem, but even with handshaking it drops characters above 9600baud and protocol transfers have to do lots of retries at 19200 and above. It may be that the tty on the *NIX system isn't really doing RTS/CTS even though I told it to. Zmodem receive works OK, but sending fails. Ymodem send works fine. Using the 'lrzsz' package from NetBSD pkgsrc which provides [XYZ]-modem protocols. I dug around in my stash and found my Big Box O'EPROMs. There are loads of 27x64/128/256/512, but precious few 2716 or 2732. I could wire up the larger EPROMs to run in the 24-pin socket, but I don't know if there's room around the socket on the board for the overhang at the front. I also poked briefly at the Davidge FDGEN utility for writing the OS image to the floppy disks. One of the first things it does is read the Warm Boot address from 0001,2 and assumes that it points to the floppy-disk BIOS. It proceeds to copy some disk timeout values from known offsets from the beginning of BIOS, so with my IDE bios having swapped the jump table to let me hook into the disk-related routines, the floppy-oriented utilities won't work. Since the first page of the BIOS is also where the interrupt vectors live, I could hack it to get the correct high byte from the Z80 I register (ld a,i [or ldai in the "Z80.LIB" macro definitions from DRI]). Hmm. Now that I think about it, since I swapped the jump tables, I should preserve the FBIOS's entry point since it will go to the HBIOS first anyway... This may have been a long-standing (30 years) bug... ----- Date: Thu, 12 Jun 2025 14:37:32 -0500 (CDT) Subject: Re: Getting back on TRK00 On Thu, 12 Jun 2025, John D. Baker wrote: > I dug around in my stash and found my Big Box O'EPROMs. There are loads > of 27x64/128/256/512, but precious few 2716 or 2732. I could wire up The first one I tried, a Motorola TMS2716C failed programming. The second was an intel 2716-1 and it successfully programmed and verified. I need to do some cleanup so I'll have space to take the machine back apart to try my new ROM--mostly recovering from digging out network and phone cabling junk to find the tools and parts I needed. The issue with FDGEN and other Davidge utilities seems not to be with my BIOS extension and the swapped jump tables but with similar patching done by the NZ-COM system to intercept BDOS and BIOS calls. Turning NZ-COM off restores stock DRI CP/M 2.2 and CCP (actually, I patched in "ZCPR-D&J" a long time ago, so it's not the stock CCP but quite enhanced and has all the usual (and more) resident commands). Looking at the Warm Boot address in 0001,2 show it pointing at the stock floppy-disk CBIOS's Warm Boot entry point (the contents of which were swapped with those of my extension when it was initialized.) I need to look at those utilities more closely to see how tied are they to the BIOS versus doing things internally. That is, if I tell it to operate on drive A, will it expect that to be the first floppy disk from the BIOS perspective or just assume it's disk 0 and operate on it directly? While hunting for my Big Box O'EPROMs, I found some more scavenged EPROMS (27256 and 27512) that need the old label adhesive cleaned off and contents erased... ----- Date: Thu, 12 Jun 2025 21:03:54 -0500 (CDT) Subject: Re: Getting back on TRK00 On Thu, 12 Jun 2025, John D. Baker wrote: > On Thu, 12 Jun 2025, John D. Baker wrote: > > > I dug around in my stash and found my Big Box O'EPROMs. There are loads > > of 27x64/128/256/512, but precious few 2716 or 2732. I could wire up > > The first one I tried, a Motorola TMS2716C failed programming. The > second was an intel 2716-1 and it successfully programmed and verified. > I need to do some cleanup so I'll have space to take the machine back > apart to try my new ROM--mostly recovering from digging out network and > phone cabling junk to find the tools and parts I needed. And I did have to seriously disassemble the case and internal supports in this old Leading Edge PC case I mounted the Davidge in so long ago. The ROM is right under the "bridge" that carries the power supply at the back and the floppy drives at the front. There are cutouts in the "deck", but the ROM is squarely under a solid portion. IT WORKS! It takes a while for the floppy code to decide it failed, but then the 'ideload' routine loads the boot sector and the boot sector loads the system and off we go! The only annoying thing is the floppy drive motor is left running until the first access completes. If the hard disk boot succeeded and you don't need to access that floppy, it will stay running indefinitely. Short of yet another ROM revision, I could probably put the relevant code to turn off the floppy motor in the hard disk boot sector. Also, booting from floppy still works, too. Both floppies and the IDE drive are tied to the same power harness, so disabling the hard disk means no floppies either--except the first floppy is a 3.5" drive and uses a connector adapter for power. So, I could power just the A: drive and test the monitor. Then unplug the single drive and re-plug the full harness to test booting from the monitor. Need to dig through my stash of IDE cables and get a 2-drive cable to see if the GIDE and CP-342 play nice with a CF adapter. While I only have 2 screws holding it together, I should do as much as I can before I have to put it back together. > While hunting for my Big Box O'EPROMs, I found some more scavenged > EPROMS (27256 and 27512) that need the old label adhesive cleaned off > and contents erased... Actually quite a few 2764s as well... That label adhesive is some tenacious stuff! My usual chemical of choice is paint thinner, but that barely softens the stuff. I don't know how the markings are applied to the ceramic capsules, so I didn't dare use anything harsher like acetone, brake cleaner, or carb cleaner. So with repeated applications of paint thinner, scraping with a letter-opener and buffing on a paper towel, I got all the goo off. I can only erase up to 7 28-pin EPROMs at a time in my eraser, so I had to run three batches. They all verified as erased. ----- Date: Fri, 13 Jun 2025 06:40:54 -0500 (CDT) Subject: Re: Getting back on TRK00 On Thu, 12 Jun 2025, John D. Baker wrote: > IT WORKS! > > The only annoying thing is the floppy drive motor > is left running until the first access completes. If the hard disk boot > succeeded and you don't need to access that floppy, it will stay running > indefinitely. Short of yet another ROM revision, I could probably put > the relevant code to turn off the floppy motor in the hard disk boot > sector. I think the main issue is that nothing ever de-selects the floppy (and they may be set to turn the motor on when selected). I patched the hard-disk boot sector to write a control byte to the floppy DCTRL1 register (external to the FDC) which explicitly turns the motor off and de-selects all drives. I think I will update my ROM to do likewise if a valid boot sector was sucessfully loaded from the hard disk. > So, I could > power just the A: drive and test the monitor. Then unplug the single > drive and re-plug the full harness to test booting from the monitor. Monitor seems to work OK although the P)ort examine/modify doesn't seem to work. I tried using it to send the motor-off/de-select-all byte to the DCTRL1 port, but it didn't work and subsequent reads of the port returned weird values. ----- Date: Fri, 13 Jun 2025 18:26:36 -0500 (CDT) Subject: Re: Getting back on TRK00 I've added the code to set "MOTOR OFF" and de-select all floppy drives to my ROM code. I also found a couple more unbalanced stack operations I hadn't caught before. Same solution, pop the old return address before jumping to the routine. "H)elp" just jumps back to the start of the monitor to re-display the command summary which pushes the address of the command processor. "B)oot" jumps back to the floppy/SASI(IDE) load routines. I found the bug with the "P)ort" command. Incomplete edit on my part. The original code (D3115ROM.ASM) didn't take advantage of some Z80 features, but "4000ROM.ASM" does. Namely, that register-indirect I/O can be done with _any_ general-purpose register. Since the byte to output was saved in B while A was used to check if the user pressed Carriage Return, the old code explicitly did: ld a,b out (c),a while the newer code simply did: out (c),b (or rather the Z80.LIB macro definition thereof). I missed that subtlety when I was grafting 4000ROM changes into the D3115ROM code. I also added a mechanism to explicitly drop to the monitor. If the user presses Ctrl-C while waiting for the floppy boot routine to fail, it will jump to the monitor. I had to slightly re-work the routines that read from the console so that checking input status was separate from reading a character. At least, that's the theory. I'll need to go through the whole dance of getting my code from the Davidge to the machine where my EPROM programmer runs... ----- Date: Sat, 14 Jun 2025 06:28:44 -0500 (CDT) Subject: Re: Getting back on TRK00 So, it's good that I switched on debug mode as I found more bugs. They're not mine this time. I don't see how the 4000ROM monitor code could have worked for the S)et and P)ort commands. The D3115ROM's ASCHEX routine to convert an ASCII character into a hexadecimal digit value was non-destructive unless the character represented a hexadecimal digit. It had a corner case though because if A='G' cp a,'G' doesn't carry, but it results in Z=0 which the routine uses to indicate that the byte returned in A represents a successful conversion. The 4000ROM's version of the ASCHEX routine is destructive to anything less than '0', and only partially restores the byte if it didn't represent a hexadecimal digit, but it handles the above corner case. I only needed to make a couple of changes that added 2 bytes to the routine but I got those 2 bytes back not having to re-add '0' to the value returned when a non-hex-digit character was passed in. It is also fully non-destructive for ASCII values between '9' and 'A' or greater than 'F'. The S)et and P)ort commands each contain an identical code sequence to collect and convert the second digit of a byte to be placed in memory or sent to a port. I finally figured out how to convert it into a subroutine and eliminate the duplicate copy. That's what led me to find the bug(s) in the ASCHEX routine. When you only needed a single-digit entry, the ASCHEX routine was returning 0DH-30H but the parsing code was comparing that to 0DH (carriage return) and bombing off to the error exit. Now that I think about it more, I may be able to de-duplicate more of the common code between S)et and P)ort. ----- Date: Sat, 14 Jun 2025 17:01:22 -0500 (CDT) Subject: Re: Getting back on TRK00 So after fixing the ASCHEX bugs and factoring out an even bigger block of code common to both the S)et and P)ort commands, I had quite a bit of space available for activities. So, instead of my hackish "catch a Ctrl-C after the floppy load fails", I implemented a simple boot menu with a 5-second countdown (for CPU busy-loop values of "second"). During the countdown, it checks for a character in the SIO receive buffer (since I already split status and input functions) and if any key is pressed, it checks: H-boot Hard Disk F-boot Floppy Disk M-drop to ROM Monitor If the countdown expires, it jumps to the standard sequence of trying the floppy, then the hard disk up to ten times each. Pressing anything other than [HFM] will abort the countdown and wait until one of the 3 valid options is pressed Still tinkering with some options such using string output rather than discrete calls to CHROUT for the countdown display. It works in the debugger. I suppose running the ROM Monitor under DDTZ is Debugger-ception... ----- Date: Sat, 14 Jun 2025 20:47:24 -0500 (CDT) Subject: Re: Getting back on TRK00 > On Sat, Jun 14, 2025 at 6:28AM John D. Baker > wrote: > > > It had a corner case though because if A='G' > > > > cp a,'G' > > > > doesn't carry, but it results in Z=0 which the routine uses to indicate > > that the byte returned in A represents a successful conversion. I got things backwards. It's Z=1 (operation result is zero). Doing silly string pointer tricks. Since I put my countdown string immediately after my bootmenu string, I just needed to bump HL past the NULL byte to point to the countdown string (00,08,00), load the display digit into the string directly: ld (hl),'5' and decrement it for the countdown: dec (hl) (or rather the Z80.LIB macro definition of those since that's what DRI's MAC macro assembler understands, so it's more like: mvi m,'5' and dcr m Just had to push HL before calling the print routine and pop it after it returned. I finally decided it was time to burn the next iteration of the boot ROM and getting the file from the Davidge to the NetBSD system was being challenging. I think the key is setting the terminal to 'raw' mode before starting the receiver ('lsz'). It's the first time I've had a Zmodem receive work. Once I got the file onto the machine running the EPROM programmer, it took a little longer to program as I had to use a GENERIC 2716 profile since no part by manufacturers with names starting with "F" matched the part I had. It's freakin' cool! ----- Date: Sun, 15 Jun 2025 10:53:45 -0500 (CDT) Subject: Re: Getting back on TRK00 For anyone curious about the Davidge DSB-4/6, there's actually some data at: https://bitsavers.computerhistory.org/pdf/davidge/dsb-4_6/ I don't know where the enclosure in the photos comes from because I got mine from a friend in a plywood and laminate case with a much-too-flexible, poorly-cut sheet of aluminum serving as a mount for the board, power supply and 2 8-inch SS floppy drives. The power was so sketchy that I didn't even know the board supported power-on RESET until I moved it to the reclaimed Leading Edge PC case. The "1538A.BIN" firmware appears to be an earlier version of the 4000ROM.ASM file. It contains the version string 1.0 while the files I have say 1.3. In the small bit I looked at, it's missing a few instructions compared to the file I have. Still has the same bugs, though. Perhaps when I can get everything together I can expand their collection--particularly in the firmware department. I have RESOURCE, ZESOURCE, and REZILOG, but I either don't have, can't find, or can't access the documentation (if it's on 8-inch floppy as I don't have one set up). T3h int4rw3bz are of little help. The closest I've come is a page on DASM which has been enhanced from Richard Conn's original v1.5 which is itself based on ZZSOURCE by Dave Barker which is based on RESOURCE by Ward Christiansen. The only documentation appears in the sources for the DASM H)elp display which apparently doesn't exist in the versions of the tools I have. ----- Date: Mon, 16 Jun 2025 21:13:20 -0500 (CDT) Subject: Re: Getting back on TRK00 So, I ultimately decided that it is bad form to have the ROM code write into the boot sector, even if it's a well-defined interface. Instead, I should follow the example of the floppy-disk ROM code and pass in the relevant information in registers. As the floppy code passes the control byte for selecting from which disk it loaded the boot sector in "A", I do likewise with the IDE ROM code and pass the SDH register value for the unit/head from which the boot sector was loaded. Fortunately, that scheme is compatible with the current ROM as "A" has the value it just stored in the last byte of the boot secotr right before the ROM jumps to it. The new hard disk boot sector code simply saves "A" in the same place, so it doesn't really matter. If I bother to re- burn an EPROM, it will not write into the boot sector. So then I returned to my IDEGEN utility which was languishing with unfinished revisions after my last debugging session left me rather disturbed due to the bizarre behavior of SAVE. I re-implemented a few things to make them smaller, or just because I thought they were a nifty way to do things (such as zero-ing a block of memory with the LDIR instruction). I added code to compute the number of host sectors the boot sector needs to load if the OS image was read from a file. If the computed result is the same or smaller than than what's already in the next-to-last byte in the boot sector, we replace it. Also, the routine to write the system tracks puts the SDH byte for the "disk" (really which head of the disk) in the boot sector before it writes the system tracks to disk. I need to find a utility to "trim" a file by one record. Since SAVE (and DDTZ's Write command) only save at page-size resolution, the system file is 1 record longer than it needs to be so my sector-count calculatons always end up 1 (host) sector longer than necessary. Fortunately, the calculations done when assembling the boot sector code result in the correct mininmum number of sectors. When I got to a good spot, I ran the assembler over the IDEGEN source, transferred a copy of the listing file to the *NIX host and printed a copy so I could properly grovel over it and be able to see multiple parts of the code at once. The goal was to make the return values for all functions compatible (A=0,Z=1 for error; A=FF,Z=0 for no error). I ended up replacing some spaghetti jumps/branches with conditional returns (ret z) and realizing that some stack gymnastics just weren't necessary (no need to pop a return address when the routine should be entered with JP instead of CALL). The utility is smaller than it was before yet with more features. With that finally finished, I wrote new system images to each of the "disks" (heads) and pressed the reset button. Nice. For completeness, I added head-cycling code to my chain-loading and hard-disk-loading floppy disk boot sectors, to mimic the ROM code's behavior. The chain-loader passes the the HD boot sector the SDH byte in A. ----- Date: Wed, 18 Jun 2025 10:12:05 -0500 (CDT) Subject: Re: Getting back on TRK00 On Mon, 16 Jun 2025, John D. Baker wrote: > I ended up replacing some spaghetti jumps/branches with conditional > returns (ret z) and realizing that some stack gymnastics just weren't > necessary (no need to pop a return address when the routine should be > entered with JP instead of CALL). In the not-leaving-well-enough-alone department, I realized the same applied to the ROM code. The error-exit routine pointed at the error string and jumped back to before the beginning of the Monitor's command-processing loop so it would call the message display routine and return to the beginning of the command processing loop. Since I had made sure to keep stack operations balanced, instead of POPping the return address and branching back to before the beginning, just jump directly to the message-display routine and it will return to the start of the Monitor's command-processing loop. Doesn't decrease code size since I have to use a jump rather than a branch, but I feel better about it. The only places where POPping the return address and jumping/branching to a routine are needed are for the H)elp display or to go back to the B)oot routines. ----- Date: Tue, 1 Jul 2025 18:15:16 -0500 (CDT) Subject: Switching between multiple hard disk partitions in CP/M? I've begun wrestling with an issue now that I'm poised to attach other storage (such as CF cards) to the Davidge DSB-4/6 w/GIDE interface. With the availability of HYOOGE! storage and the ability to interface it to our favorite small systems comes an interesting problem: how to use all that space within the constraints of CP/M? Sure, multiple partitions, but CP/M limits you to 8MB maximum/partition and only up to 16 drives (some of which should likely remain floppy drives). Way in the BBS era, I dialed up Houston N/W RCP/M Znode #45 in Jersey Village regularly. ISTR it was running on a TeleVideo machine and had more physical hard disks/partitions than it could address at any one time. It had a custom BIOS that would swap out one group of disks and/or partitions for another when a request was made for one that wasn't in the current active set. Normally, hard disks don't have any CSV space allocated as they're (usually) never changed. To make it possible to swap partitions in CP/M and have it do the right thing, perhaps a unique directory entry for a zero-length file guaranteed to be in the first directory block (like, say, a DISKLABEL? ;) and only enough CSV space for the first directory block (or maybe only the first N entries?) would be enough for CP/M to discern that a disk was swapped out without eating too much memory. If you're using ZDDOS or DateStamper, it wants the "!!!TIME&.DAT" file to be first in the directory, and the setup utility will move directory entries and file data accordingly. The ZNode #45 BIOS made the swap somewhat transparent to normal operations When one requested a drive/user combination that wasn't currently active, the system wrote a message to the (remote) console, swapped and logged in the alternate drive set and then you were logged into the requested drive/user. ISTR that the drive letters did change, if, say, A: and B: are the floppies, C: and D: are permanent hard disks or partitions, then one group of E:-H:, I:-L:, or M:-P: would be available and the others moved to offline status. My decision 30 years ago to operate each head of the hard disk as as separate drive/partition now shows how short-sighted and/or naive I was at the time, but I was (nearly) the first to implement a BIOS extension for the brand-new GIDE device that only appeared a few months before. I was reading web pages of others who've incorporated the GIDE logic if not the device itself into their system designs or expansions. I came across one guy who seems to have a really good scheme and I'm pondering adopting it. http://www.ardiehl.de/gide/ Perhaps keep 2 disk partitions as "permanent" and define groups of partitions that get swapped in/out when accessed and a utility to mark partitions as part of a particular group. ----- Date: Wed, 2 Jul 2025 02:43:30 -0500 (CDT) Subject: Re: Getting back on TRK00 So, I'm trying to get set up to play with multiple physical units on the GIDE board, primary/secondary (master/slave although that concept doesn't really apply). Turns out, I've been using perhaps the _worst_ possible disk for my development work. The Conner CP-342 earns a big, fat "U" (an F-U if you will) in the "Works and plays well with others." category. It is so bad that some Western Digital IDE disks of that era had a special extra jumper _just_ to handle the case where a Conner CP-342 was installed as the master/primary drive. In fairness, I did have the drive set to "single" as per the only config data I found. Setting it to "Master" changed nothing. Accesses to the device attached as the secondary unit was either garbage or garbled. Setting the CP-342 to slave/secondary seems to work like a charm and with a SanDisk CF card as primary in an IDE-CF adapter, both units are visible and appear to return the correct data. So, I needed to boot from the secondary unit. One thing I learned is that I need to make the ide boot code in the ROM more robust. It needs a power-up delay for the first time it tries to access an IDE disk. It also needs to be more selective about just jumping to any old sector it happens to load from a hard disk. The CF card has a standard DOS MBR on it, so it went nuts and corrupted the RAM copy of the ROM code to the point it required a power-cycle to straighten out the FDC again. I got out my boot floppies which boot the 62K system and run the GBIOS62.COM loader as a turnkey command--specifically the version that leave the floppies as drive A:-D: and the IDE disk as drives E:-I:. I patched the file to use "Bx" for the secondary unit instead of "Ax" for the primary unit for the SDH byte sent to the Task File registers. There was a moment where things still didn't work because I forgot that there are 2 places to patch, one in Select Array that is used by SELDSK: and the other that gets used during disk access for the actual SDH value to OR in to the "disk" (head) value. Once I got that straightened out, I could access the disk and make the same patch to one of the "disks" on the hard disk. When the machine boots, I drop to the Monitor right away, condition the location where the IDE boot code checks for the next "disk" to try so it contains a value for the head on the secondary unit to boot. It passes this to the boot sector code in A so the rest of the system (with the patched BIOS) is loaded from the same "disk". Preliminary tests indicate that IDE disks work just fine as secondary units with no primary attached. This will be important as I need to keep the CP-342 operational while investigating other devices. I've been reading the source code for the work Armin Diehl did for his Prof80 ECB Z80 system with his implementation of the GIDE interface and CP/M3. I can see some similarities between what I did and what CP/M3 does. I'm thinking I should implement his "MBR"-style boot sector even if I don't use that arrangement just yet. The signature string alone would be a better guard against executing random data than a simple test whether the first byte is "E5" and jumping to the code if not. ----- Date: Fri, 4 Jul 2025 02:47:34 -0500 (CDT) Subject: Re: Getting back on TRK00 On Tue, 1 Jul 2025, John D. Baker wrote: > I've been reading the source code for the work Armin Diehl did for his > Prof80 ECB Z80 system with his implementation of the GIDE interface and > CP/M3. I can see some similarities between what I did and what CP/M3 > does. I'm thinking I should implement his "MBR"-style boot sector even > if I don't use that arrangement just yet. The signature string alone > would be a better guard against executing random data than a simple test > whether the first byte is "E5" and jumping to the code if not. So I can't pick just one thing to work on. Sometimes I hack on the ROM code, then switch off to the HD boot sector, then some of the support utilities. I have updated the various utilities I wrote in C to accept a unit number (0 or 1 for primary or secondary) along with their other usual arguments. I got the ID and DUMP utilities done and learned a few new tricks. Just now, I updated the ZERO utility--perhaps misnamed since it writes "E5h" to every byte of the disk (or portion thereof as selected by command-line arguments). I've implemented a hybrid version of Armin Diehl's MBR-esque boot sector and partition table. With the disk geometry information encapsulated in the boot sector itself, I should be able to dispense with the SECID_NF tricks since I don't have to incur that error at all. There's lots of room for activities. It's a hybrid in that, for compatibility with my current scheme, it claims the disk has only 1 head and it incorporates the "paritition boot record" as well (contains DPB for that partition). I got to thinking that it would be convenient to be able to call ROM routines from the boot sector, so I rearranged the ROM code to have a jump table similar to the BIOS. It's mostly the console routines that are implemented. Anything else jumps to the Monitor. The hybrid MBR-esque boot sector seems to work in test mode. I need to update the IDEGEN utility to deal with multiple physcial units so I can write a system image with the new boot sector to the secondary unit. Then I can run the ROM code in test mode. ----- Date: Sun, 6 Jul 2025 17:54:20 -0500 (CDT) Subject: Re: Getting back on TRK00 On Fri, 4 Jul 2025, John D. Baker wrote: > I've implemented a hybrid version of Armin Diehl's MBR-esque boot sector > and partition table. With the disk geometry information encapsulated > in the boot sector itself, I should be able to dispense with the SECID_NF > tricks since I don't have to incur that error at all. There's lots of > room for activities. It's a hybrid in that, for compatibility with my > current scheme, it claims the disk has only 1 head and it incorporates > the "paritition boot record" as well (contains DPB for that partition). I finally got that working, at least in test mode. It's the first time I've used the multi-sector read capability by setting the Sector Count register to a value greater than 1. Telling it the drive has only 1 head makes it work for the current arrangement. Some experiments confirm that a multi-sector operation proceeds in cylinder-major order. I need to update my IDEGEN utility to request a unit number along with the head (for legacy support). Maybe I'll just call them partition numbers. Maybe another query for partition by head or partition by cylinder. If there's a partition table on the disk already, it can read data from it. If not, there'll need to be some override or read the partition table from the boot sector in the system image (if it was loaded from a file). I should look at Armin Diehl's 'fdisk' utility and either convert it from Pascal to C or figure out if I have a copy of Turbo Pascal anywhere that I can get onto the Davidge. I know it's on my Apple CP/M systems, but I can't physically access them right now. The test-mode ROM is starting to get tight on space even after tightening the message strings a bit more. I've got it alternating between primary and secondary units on each retry and if it's the first access it's supposed to wait 10 seconds before accessing the disk and it now sends a RESTORE (or HOME or RECALIBRATE depending on who you ask) before doing anything else (important for drives with stepper-motor head positioners). I say _supposed_ to wait 10 seconds, but it seems more like 120 (or more, I haven't actually timed it) before it accesses the disk. ----- Date: Thu, 10 Jul 2025 20:50:41 -0500 (CDT) Subject: Re: Getting back on TRK00 Anxious to get my hybrid MBR-esque/PBR boot sector on the disk, I just h4xx0r3d a simple program to write Cylinder 0, Sector 1, of a given head right in DDTZ just above where I'd loaded the boot sector from 100,2ff. That got the bootsector installed. I saved it as INSTBOOT.DDT. I'll write a proper "installboot" utility eventually. Then I turned back to the next generation of the ROM code. I found my bug that was making the spin-up delay take so long. I branched back to the wrong label so instead of reloading B with the cpu scale factor, it was looping the whole 256 times. I also added polling the DRV_RDY bit (bit 6) in the status register so when the drive(s) report(s) ready, the loop will exit early. My empirical "feels like 1 second" delay values were not far off. I ultimately counted up all the T-states in the loops plus call, return, branch taken/not taken, etc. My "feels like" delay for about 50ms was 8000 (decimal), the calculated value is 7692, a 4% error. My cpu scale factor of 20 turned into a scale factor of 26, but since that didn't divide evenly for a 6MHz machine, I dropped it to 24, for errors of 23% and 17%, respectively. I recently deciphered several more bytes in the CBIOS which turn out to be head-load delays for 8-inch and 5-inch disks, head-settling time and motor-on delays. They were just the number of milliseconds and their calibrated delay loop uses a value of 40 times the CPU speed in MHz for the scale factor (MSB of loop counter). The idea of making ROM routines available to the boot sector code or early BIOS boot routines got scaled back quite a bit when I realized that code below 0100h would be overwritten when the BIOS takes over, so instead of a jump table at 0000, I have an array of function pointers at 0100h for ROM versions of CONST, CONIN, CONOUT, a printstring routine, and the 50ms delay routine. Some things I realized were single-use only, so just folded them into the code inline rather than make a subroutine. That saved the call/return overhead both in size and time. In particular, doing discrete comparisons for the signature string "CPM" in the boot sector was shorter than calling the "strncmp" routine and eliminated the need to keep a copy of the string in ROM. New ROM is running now so I can think about how to migrate the BIOS extension to the new scheme. The bootsector (and most of the ROM code) will still be resident and unaltered when the BOOT routine(s) are running, so my loader can install values in the BIOS. I think it will work something like this: If the partition starts in Cylinder 0 and the disk is claimed to have only 1 head, the first N partitions are on each of the first N heads. Otherwise, the partitions start at a cylinder > 0 and start with head 0, sector 1 of that cylinder. The hybrid MBR/PBR contains the DPB for a partition. So, resident data for each disk will need to be something like: Unit (0/1, primary/secondary) (w/head for legacy system) Start cylinder DPB[unit][num] Unit data will be something like: Heads Sectors/track DPB0 DPB1 I figure only have 2 DPBs per unit, one to handle as many maximum-size partitions as will fit and the other to handle a smaller partition to fit any remaining space. I'll probably only support 4 hard-disk resident disks as I'll need space for more data and code to support the new arrangements. I figure on cold boot, all disk slots will be initialized from the first 4 partitions on the unit from which the system booted. As a first approximation, I'll probably come up with a utility to switch out disk partitions. The common read/write code w/sector deblocking will need to determine which head a sector is on. Probably encode that as the MSB of SEKHST and HSTSEC. Everything else is 16-bit, but the host sector numbers will eventually reduce to 8 bits. I've already done some rearrangement so I can point HL at the first HST* item and walk up the bytes, plugging them into the various Task File registers more-or-less in order (might need to go back and see if I can use register-indirect addressing and whether that will save space over "ld a,(hl) ! out (iRgFoo),a" So, I was hoping to use 22DISK to transfer data between the Davidge and DOS/UNIX, but I discovered that it operates the FDC in the Dell Optiplex 110 at 300kbps instead of 250kbps, even if I tell the BIOS the drive is 360K 5.25". To work around this, I format a disk with 22DISK for the Davidge format, image it with IMD, then turn around and re-write the disk from the image, doing 300K->250K conversion. Then I can read the disk in the Davidge. I'll need to check if doing the opposite conversion will produce a disk originated on the Davidge that 22DISK can read. I was hoping to produce a disk image with IMD that was bootable, but writing the disk from an image results in track0 sector 18 (single- density 128 bytes) being bad on the Davidge. ----- Date: Sun, 13 Jul 2025 15:30:50 -0500 (CDT) Subject: Re: Getting back on TRK00 Taking a break from IDE hacking a bit, I've been working on how to add to the rather sparse information there is on the Davidge DSB-4/6. There are photos and ROM images on bitsavers and a couple of videos on YouTube of running the "1538A.BIN" ROM image under MAME, but that's it. I probably have the most complete collection of Davidge material there is and it needs to get out to the rest of the world. I assembled what I consider a "minimum viable boot floppy" that will work on 3.5" or 80-track (300RPM) 5.25" disks. It boots a 64K plain CP/M and contains all the materials needed to write a BIOS plus a couple of nice utilities. I've copied the files to *NIX so I can make a zip archive of them (LBR would be more traditional but anyone handling these files will likely be starting with some type of unzip utility on a PC, whether DOS, windoze, or some flavor of *NIX so it wouldn't be fair to introduce another "bootstrap" problem.) So then I needed to see about reading disks produced on the Davidge on a PC. Decades ago, I actually registered 22NICE and 22DISK from Sydex. I even created some custom disk definitions so I could read HD5.25" disks written with the SVA ZVX4 8-inch floppy controller in my Apple //e. I had all the formatting and DPB information from my disassembly of the FD-4000 BIOS, so it was no problem to whip up definitions for the Davidge (I've since learned that the Davidge uses the same 5.25-inch (3.5-inch) disk formats as CCS although mine are 80-track versions rather than 35- or 40-track.) Meanwhile, I came across something that purported to let me regenerate a complete relocatable CP/M with a custom BIOS attached. It was, however some file with an ".IMD" suffix. That led me down another path of learning about Dave Dunfield's IMageDisk utility. The file I had was the result of using IMageDisk (IMD.EXE) to analyze and capture the data from an SSSD 8-inch floppy disk. I don't have space to get out my 8-inch drives nor to hook them up to anything, but I did have the 1.44MB 3.5" drive in the Dell Optiplex GX-110 I was using. As long as I used a proper HD floppy that could handle the data rate, the fact that it spins at 300 RPM vs 360RPM shouldn't really matter. And it didn't. I wrote the image to the disk and was able to read it with 22DISK's "A1" disk definition for SSSD 8-inch disks. Sweet! It then occurred to me that this could be a way to archive the Davidge boot floppy so anyone who got the IMD file could re-generate bootable media for their DSB-4/6. I set everything up and packed as much information into the comment field of the IMD file as I could. The imaging operation went off without a hitch. But that was about the end of it. 22DISK couldn't read the 3.5-inch boot floppy and the Davidge couldn't boot from a disk written by IMD from the image file I'd just created (although the data area was intact). I left things at that for a while then I decided to see what was going on. I'd re-read the documentation in the Davidge manual about 'FDCOPY', that it does a track-by-track read of the source then a track-format and write of the destination. If the same drive were both source and destination, it would read-format-write over the disk, "freshening" it up. I tried this with the floppy written from the IMD image. The only failures were the last sector (18, SD) on each side of track 00. Whatever the boot sector encountered when it hit that sector (side 0 only for boot tracks), it doesn't even seem to have tried to start over because the floppy IN USE light has gone out. Then I turned to try and figure out why 22DISK can't read the Davidge disks and conversely why the Davidge can't read disks written by 22DISK. I used my disk definition for DD 256-byte sectors, 80 tracks to format a disk with the "CFMT.EXE" utility, then I imaged that disk with IMD. For some reason, when told to use the "LOW" data rate, 22DISK was choosing 300kbps rather than 250kbps. I even set the machine's BIOS to tell it the drive was a 360K 5.25-inch disk, it still used 300kpbs when reading or writing a DD 3.5-inch disk. Then I used IMD to write another disk from the "minimal system disk" image I'd made and told it to perform 250k->300k conversion. When the disk was finished, 22DISK could read it. Then I wrote the files I recovered from the 8-inch image to the disk formatted for Davidge at 300kbps, imaged it, and re-wrote it using 300k->250k conversion. Then the Davidge could read the disk. I wonder if my version of 22DISK is just old enough to not understand the 3 data rates needed. I checked a disk formatted for DOS 720K and IMD reported it as being written at 250kbps like it's supposed to be. 300kbps is perfect if I'm using a HD5.25 drive but there isn't one installed in this machine. While there is a drive bay available for one, I don't have space to get the machine out and install one. I need to build a break-out board that lets me assign any drive-select to any drive without having to fiddle with the drives themselves. If the 3.5-inch drive won't boot, maybe the 5.25-inch drive will, but I have to disassemble everything to change jumpers. And possibly also a companion board/cable at the drive so I can use the more recent drives that are fixed at DS1 only. I'd whip up a cable to let me put a 1.44MB drive on the 8-inch drive port, but even if I remember where all my connectors are, I can't get to them. More recently, while shuffling through the 5.25-inch disks I have for the Davidge (and re-formatting a bunch of random reclaimed disks), I ran across one I'd labelled as the "ZMP v1.5 Install Disk". Sure enough, it had the customized overlay source for the Davidge--but it wasn't the most recent. The sources I found all implement the 256-byte FIFO w/RTS/CTS flow control, but none of them used interrupt-driven receive and I most definitely have interrupt-driven receive--at least on SIO 1B and 2B, but not on SIO 2A. Davidge arranged for all ports to be wired as DCE when using a straight- through ribbon cable with an IDC 2x13 connector on one end and an IDC DB-25 connector on the other--except port 2A which is wired as DTE and is the designated modem port (it has the highest interrupt priority of all the serial ports). When I put the Davidge in the Leading Edge case, I wired ports 2A, 2B (also called SIOC and SIOD in PORTDEF.LIB) both as DTE with PC-style DE-9 connectors. Why I don't have interrupt-driven receive for that port I can't really remember but it must have to do with the fact that the IVL register and "status-affects vector" control bit only exist in channel B of the Z80 SIO. While the IVL register can be read back, WR1 (w/"status-affects- vector" bit) is write-only, I was hestiant to write to a register of a port I wasn't using. Since then, I've been doing a crude disassembly of the interrupt-capable executables so I can re-constitute the custom overlay sources and add interrupt-driven receive to the copy of ZMP that operates SIO 2A. ----- Date: Thu, 17 Jul 2025 21:14:03 -0500 (CDT) Subject: Re: Getting back on TRK00 On Sun, 13 Jul 2025, John D. Baker wrote: > Since then, I've been doing a crude disassembly > of the interrupt-capable executables so I can re-constitute the custom > overlay sources and add interrupt-driven receive to the copy of ZMP that > operates SIO 2A. And, thanks to recent work by Wayne Hortensius, I was able to read the actual source code for ZMP itself so I could learn how and, more impor- tantly, _when_ various functions were called. I was also concerned that there was an entry for the ISR in the ZMP overlay jump table--the main program shouldn't have any knowledge of that. grepping the sources showed that it was likely just a placeholder to aid debugging. After looking at the calling sequence of the overlay routines, I was confident to use the "invec:" and "deinvec:" entry points to initialise and de- initialise the interrupt vector for the SIO (overlay the space that would normally be used for CTC02 since it's the baud-rate generator for SIO1B (aka SIOB) and thus will never interrupt). I removed a couple of DI/EI pairs that were superfluous and that had a noticable improvement in performance. The only thing my overlays do that's out of the ordinary is that I hijack the initial jump at 0100h so I can steal 261 bytes for my FIFO, head and tail indices and a BDOS redirection jump before continuing with ZMP. Otherwise, ZMP will take all of TPA up to the start of BDOS for itself. Since I now knew the order in which the routines in my overlay would be called, I could eliminate a bunch of stuff. My "steal" routine originally went on to initialize the interrupt vector and set the UART default speed and operating mode (data/parity/stop). The interrupt- vector (de-)initialisation was moved to the areas ZMP already provided and none of the other stuff (other than stealing space) was needed. The only odd thing is that when you change port speeds the first time, you have to also explicitly set the mode, even if its the same, otherwise nothing will be received. Even more odd because it's just calling the same "init:" routine for both speed and mode changes. Otherwise, it works a treat. ZMP only supports up to 76800bps, the baud- rate generators can't do that. They can do 115200bps, so that's what I have the 76800bps entry set. 710bps is a strange speed, but it's one that ZMP supports. A time constant of 162 in counter mode generates that with only 0.16% error. After that, it was just a few EQUate changes to regenerate interrupt-driven-receive overlays for each of SIOB and SIOD (SIO1B, SIO2B) as well. Easing back into IDE-related stuff, I updated my chainloading floppy boot sector to check for the "CPM" signature string and do the same unit-bit flipping and head incrementing as the ROM code. I plan to see if I can get the floppy-disk HD boot sector to do the multi-sector reads that the new HD boot sector does. Then I need to tackle IDEGEN again so it can read/write from/to the secondary unit. Then I can start testing BIOS mods to migrate to the new partitioning strategy. It seems that the Davidge ROM loading the floppy-disk boot sector over itself at 0080h is a result of them mimicing CCS. The CCS FDC ROM loads the boot sector at 0080h. And, as I mentioned before, all of the floppy formats the Davidge supports are identical to those used by CCS. Since I have a CCS S-100 system, I should dig it out and play with it as well. Somewhere I have 5 bare GIDE boards that need building up (and see if any of the salvaged GALs I have can be reprogrammed). ----- [to be continued...]