User`s guide
Section 4
Programming Examples
The programs presented in this section illustrate how to use the BDOS functions
described in the previous section. The examples show how to copy a file, how to
dump a file, how to create or access a random access file, and how to write an RSX
program.
4.1 A Sample File-To-File Copy Program
The following program illustrates simple file operations. You can create the pro-
gram source file, COPY.ASM, using ED or another editor, and then assemble
COPY.ASM using MAC. MAC produces the file COPY.HEX. Use the utility
HEXCOM to produce a COPY.COM file that can execute under CP/M 3.
The COPY program first sets the stack pointer to a local area, then moves the
second name from the default area at 006CH to a 33-byte file control block named
DFCB. The DFCB is then prepared for file operations by clearing the current record
field. Because the CCP sets up the source FCB at 005CH upon entry to the COPY
program, the source and destination FCBs are now ready for processing. To prepare
the source FCB, the CCP places the first name into the default FCB, with the proper
fields zeroed, including the current record field at 007CH.
COPY continues by opening the source file, deleting any existing destination file,
and then creating the destination file. If each of these operations is successful, the
COPY program loops at the label COPY until each record is read from the source
file and placed into the destination file. Upon completion of the data transfer, the
destination file is closed, and the program returns to the CCP command level by
lumping to BOOT.
4-1