Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!psuvax1!psuvm!brl102 From: BRL102@psuvm.psu.edu (Ben Liblit) Newsgroups: comp.sys.apple2 Subject: Re: Fast reading of floppies... Message-ID: <90069.141109BRL102@psuvm.psu.edu> Date: 10 Mar 90 19:11:09 GMT References: <14075@fs2.NISC.SRI.COM> <14076@fs2.NISC.SRI.COM> Organization: Penn State University Lines: 51 In article <14076@fs2.NISC.SRI.COM>, cwilson@NISC.SRI.COM (Chan Wilson) asks: > >How do those fast disk copiers work? First of all, try to do all of your disk access at once. It takes time for a floppy disk drive's motor to get itself going, and all your program can do in the meantime is wait. Once you've got the motor cranked up, try to get everything you'll need in rapid sequence, so that the motor doesn't have time to shut off after one read before being turned on again for the next. Secondly, write tight code. This is particularly applicable to assembly language routines, but everyone knows the kind of effect an efficient innermost loop can have. As a brief example, suppose one wishes to perform some process x times. Rather than start from zero and count up to x, it is more efficient to start from x and count down to zero. Decrementing the loop index to zero will set automatically set the Z flag, allowing for BEQ/BNE branching. The count-up technique requires the use of a comparison (CMP, CPX, CPY) to set the C (carry) flag before branching may be performed. The extra cycles this requires add up quickly. Many other speed-gainers exist. Tight code means reduced use of subroutines. Modular design is nice, but when speed is of the essence, straightforward sequential execution is the only way to go. Efficient use of registers is also important, especially a machine that has so few. Not only are register operands faster than those that interact with memory, they take of fewer bytes of memory as well. The same applies to zero page use. Zero page access is faster than access to the rest of memory, so use it to store quick-access data that won't fit into a register. Zero page is also more space-efficient, as only one byte is required to specify an address rather than two. There is a last, rather creative tactic that I believe (I could be wrong) was used in the old Locksmith Fast Disk Backup. Apparently, Locksmith is intelligent enough to realize that since it is copying every sector off of a given track, it doesn't matter what which one it starts with. As soon as it reads a valid sector, *any* valid sector, it puts it into memory and marks it as read. It keeps this up until it has read the entire track (if it takes *too* long, it does know to flag an error). The advantage of this is that, when a drive is turned on, the location of the read head with respect to the sectors on a disk is basically random. Suppose a copy program insists on reading sector 16 ($F) first. If the drive reaches proper reading speed just *after* sector 16 has rotated past the read head, it will take an entire revolution of the disk before data retrieval can begin. By simply starting to read wherever the read head happens to be, a copy program can speed up operations considerably. Unfortunately, though, this approach is difficult to apply to most other situations. Hope this helps.... Ben Liblit BRL102 @ psuvm.bitnet -- BRL102 @ psuvm.psu.edu "Fais que tes reves soient plus longs que la nuit."