This article is from the Apple II Csa2 FAQ, by Jeff Hurlburt with numerous contributions by others.
A machine-language program is free to store whatever it wants in any file, but most programs (including DOS 3.3's own command interpreter) expect the data in each type of file to conform to certain formats: A sequential text file consists of lines of ASCII text separated by carriage returns, and ending with a $00 byte. The high bit of each character (except the $00 at the end) is set. A random-access file may be thought of as a set of mini sequential access files separated by strings of $00 bytes. Each "mini-file" begins at a file position which is a multiple of the random-access record length. (Note that sequential and random-access text files share the same file type. It is up to individual programs to know whether their data files are sequential or random- access.) Applesoft and Integer BASIC files have the following format: Byte Meaning ---- ------- $00-01 Length of tokenized BASIC program $02-end Tokenized BASIC program Binary files have the following format: Byte Meaning ---- ------- $00-01 Load address $02-03 Length of binary image (i.e. file contents) $04-end binary image A Relocatable file contains the image of a program, followed by a relocation dictionary containing the information necessary to relocate the program to an arbitrary memory location. The file format is as follows: Byte Meaning ---- ------- $00-01 Original program load address $02-03 File length (program image + relocation dictionary) $04-05 Length of program image alone (not including relocation dictionary) $06-xx Program image $xx-yy Relocation dictionary (The format of the relocation dictionary is a bit too complex to describe here. I can provide details if anybody's interested.) The other three file types (S, A, and B) have never been consistantly defined by anybody. Several programs use these file types (especially type S) to store their private data files, but there doesn't seem to be any agreement on their internal format. For further information I recommend the book "Beneath Apple DOS" by Don Worth and Pieter Lechner. P.S. By the way, all two-byte fields in the above are stored in normal Apple II byte order, low byte first. __ By: Rubywand