[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DOS 3.3 Nibble Encoding



Phillip Vandry writes:

>I've always been amazed that it is possible to read a file into memory
>from a program less than 512 bytes long. How can this possibily be done
>in 512 bytes? Is there some secret to it?

  Okay, here's the "secret":

  The disk controller card has 256 bytes of ROM that is capable of reading
and decoding any sector from a single track (typically track 0, but whichever
track the disk drive is accessing at the time).  That's right, you only need
256 bytes to achieve that much!
  The 512 bytes in the ProDOS bootstrap code uses the disk controller ROM to
read sectors from the disk (and has a small amount of code to move from track
to track--this is easily done).  Most of the code in the bootstrap block is
geared towards searching the root volume (on track 0) for the PRODOS system
file, and loading that up.  Thus the bootstrap code knows enough about the
structure of a ProDOS disk to read a file.  As it turns out, this also fits
in 512 bytes--the process of reading a file isn't really all that hard.  If
the file is a seedling file, it's just a matter of reading one block.  If it's
a sapling file you read one master index block and in a loop read all the
blocks listed in the index.  If it's a tree file, you read one master index
block, then in a loop read each secondary index block, and in a nested loop
read each block listed in each index block.  This code is fairly straightforward
and compact when done in assembly language.
  

--
| Philip Stephens, Systems Programmer. | "Many views yield the truth.         |
| Address:  43 Malcolm Road, Braeside, |  Therefore, be not alone."           |
|           Victoria, 3195, AUSTRALIA. |                                      |
| Internet: philip@labtam.labtam.oz.au |    -- Prime Song of the Viggies      |