forge Documentation

compiling

Compiling Programs

Once you are satisfied with your program, you can compile it to a disk file, producing a program that can be run directly from DOS.

Compiling from the IDE

Press CONTROL and W and type a filename for your compiled program.

File Extensions

It is common practice to name your compiled programs with an extension of .COM or .XEX:

  • .COM - With .COM extension files you don't need to type the extension in some versions of DOS on the Atari.
  • .XEX - The .XEX name is common in modern times to distinguish Atari executables from MSDOS/Windows programs (which are usually .EXE or sometimes .COM)

Standalone Executables

Compiled programs include the full FORGE runtime, so you can distribute them alone without the IDE.

Command-Line Compiler

You can also compile a program directly from DOS by using the included command line compiler FORGEC.COM. You can provide the BASIC source and the compiled output file names in the command line; if not given the compiler will prompt you to input a file name.

Basic Usage

FORGEC source.bas

This will compile source.bas to source.xex.

Specifying Output File

FORGEC source.bas output.com

This will compile source.bas to output.com.

Integer-Only Compiler

If you don't use floating point, using the integer versions (FORGEI and FORGECI) will compile to a smaller file:

FORGECI source.bas

File Size Considerations

Floating Point vs Integer

  • Floating point version (FORGEC): Larger file size, supports all features
  • Integer version (FORGECI): Smaller file size, no floating point support

Choose the integer version if:

  • You don't need floating point calculations
  • You want the smallest possible executable
  • You're targeting memory-constrained systems

Optimization Tips

  • Use integer variables when possible
  • Avoid unnecessary floating point operations
  • Use DIM to pre-allocate arrays instead of dynamic allocation
  • Remove unused code and variables

Compilation Process

The compilation process:

  1. Parse - The source code is parsed and validated
  2. Generate - Optimized code is generated
  3. Link - Code is linked with the FORGE runtime
  4. Output - Executable file is created

Error Handling

If compilation fails:

  • Check the error message for the line number
  • Verify syntax is correct
  • Ensure all referenced functions/statements exist
  • Check for missing variable declarations

Advanced Compilation

For more advanced compilation options, see the Cross-Compiler Usage Guide which covers:

  • Multiple compilation targets
  • Custom linker configurations
  • Include paths
  • Debug symbols
  • Optimization options

Examples

Simple Compilation

FORGEC hello.bas

Compiles hello.bas to hello.xex.

With Custom Output

FORGEC game.bas GAME.COM

Compiles game.bas to GAME.COM.

Integer Version

FORGECI utility.bas

Compiles utility.bas to utility.xex using integer-only runtime.

Next Steps