11.3. The File Directive

The file directive is used like this:

        // Save a prg file containing the code segment
        .file [name="MyFile.prg", segments="Code"]
      
        // Save a bin file containing the code and data segment
        .file [name="MyFile.bin", type="bin", segments="Code,Data"]
        
        // Save one file for each memoryblock in the DATA segment
        // ('Data_Sinus.prg' and 'Data_Mul3.prg' are created)
        .file [name="Data.prg", mbfiles, segments="Data"]

        // %o in the filename will be replaced with the name of the root source file without the extension 
        // If you called the assembler with a file called Source27.asm this will output to Source27.prg 
        .file [name="%o.prg", segments="Code"]


        // Define some segments 
        .segment Code []
        BasicUpstart2(start)
start:  inc $d020
        jmp *-3

        .segment Data []
        *=$0f00 "Mul3"
        .fill $40, i*3        

        *=$2000 "Sinus"
        .fill $100, 127.5 + 127.5*sin(toRadians(i*360/256))

The content of the file is given using an intermediate segment which makes it quite flexible. See the segment chapter for all options or the disk directive sections for more examples.

The name parameter is mandatory, the rest is optional. Here are the list of specific .file directive parameters:

Table 11.1. File Directive Parameters

Parameter Default Example Description
mbfiles false mbfiles If set to true, a file is created for each memory block.
name   name="MyFile.prg" The name of the file. (%o will be replaced with root filename.)
type "prg" type="bin" Sets the file type. Valid types are "prg" and "bin"