Difference between revisions of "Atari"

From Lazarus wiki
Jump to navigationJump to search
(Atari TOS, initial information)
 
(some simplification, how to cross-compile)
Line 7: Line 7:
 
==SysCalls==
 
==SysCalls==
  
===Introduction to SysCalls===
 
 
Free Pascal supports generating Atari TOS-style system calls, also know as traps. It's not required to use inline assembly to do system calls. However, you must declare every function you're going to use in the following way:
 
Free Pascal supports generating Atari TOS-style system calls, also know as traps. It's not required to use inline assembly to do system calls. However, you must declare every function you're going to use in the following way:
 
   
 
   
Line 16: Line 15:
 
==Linker==
 
==Linker==
 
For Atari, some versions of GNU ld linker available online is known to be problematic when working together with Free Pascal. It's recommended to use '''vlink''' by Frank Wille, while compiling to Atari TOS with FPC. Specifying ''-XV'' argument enables '''vlink''' for cross compilers. '''vlink''' is open source, and it is available [http://sun.hasenbraten.de/vlink here]. Binaries are available as part of the [http://sun.hasenbraten.de/vbcc vbcc compiler package].
 
For Atari, some versions of GNU ld linker available online is known to be problematic when working together with Free Pascal. It's recommended to use '''vlink''' by Frank Wille, while compiling to Atari TOS with FPC. Specifying ''-XV'' argument enables '''vlink''' for cross compilers. '''vlink''' is open source, and it is available [http://sun.hasenbraten.de/vlink here]. Binaries are available as part of the [http://sun.hasenbraten.de/vbcc vbcc compiler package].
 +
 +
==Cross compiling==
 +
 +
To build an Atari cross-compiler, use the following steps:
 +
 +
# Install FPC the latest stable compiler, at the time of the writing of this article this is FPC 3.0.0. This will be used as the startup compiler.
 +
# Check out FPC SVN trunk into a directory.
 +
# Make sure you have Atari TOS cross-binutils and vlink in the PATH.
 +
# Go to the trunk's main directory and use the following command to build an FPC cross-compiler:
 +
<syntaxhighlight lang="bash">
 +
  make clean crossall crossinstall OS_TARGET=atari CPU_TARGET=m68k INSTALL_PREFIX="<path/to/install>"
 +
</syntaxhighlight>
 +
If you've done everything right, you should find a working Atari cross-compiler in the install path you've specified.
 +
 +
Now, lets create a default fpc.cfg for Atari cross compiling. Create a file called '''<path/to/install>/lib/fpc/etc/fpc.cfg'''. Put the following lines into that file, and fix up the paths:
 +
 +
#IFDEF CPUM68K
 +
-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET
 +
-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET/*
 +
#IFDEF ATARI
 +
-FD</path/to/atari-cross-binutils>
 +
-XV
 +
#ENDIF
 +
#ENDIF
 +
 +
Optionally add '''<path/to/install>/lib/fpc/3.1.1/''' directory to the PATH, so you'll have direct access to the cross-compiler. If you've done everything right, you now should be able to build Atari executables:
 +
 +
ppcross68k -Tatari <source.pas>

Revision as of 21:26, 8 October 2016

This page is about the Atari TOS version of Free Pascal, which means Motorola 680x0 CPU based Atari systems running TOS and compatibles. Currently, Atari TOS is only supported as a cross-compilation target. The RTL support is currently minimal and lacks functionality to run the compiler itself on Atari TOS.

Identification

To identify Atari TOS during compile-time, use {$IFDEF ATARI}.

SysCalls

Free Pascal supports generating Atari TOS-style system calls, also know as traps. It's not required to use inline assembly to do system calls. However, you must declare every function you're going to use in the following way:

function gemdos_fwrite(handle: smallint; count: longint; buf: pointer): longint; syscall 1 64;

Note the syscall modifier in the function declaration. The first argument to the syscall modifier is the trap number to call, and the second one is the trap opcode. All syscall parameters are passed on the stack and they're word (2 byte) aligned. For further examples, see rtl/atari/gemdos.inc in the RTL source.

Linker

For Atari, some versions of GNU ld linker available online is known to be problematic when working together with Free Pascal. It's recommended to use vlink by Frank Wille, while compiling to Atari TOS with FPC. Specifying -XV argument enables vlink for cross compilers. vlink is open source, and it is available here. Binaries are available as part of the vbcc compiler package.

Cross compiling

To build an Atari cross-compiler, use the following steps:

  1. Install FPC the latest stable compiler, at the time of the writing of this article this is FPC 3.0.0. This will be used as the startup compiler.
  2. Check out FPC SVN trunk into a directory.
  3. Make sure you have Atari TOS cross-binutils and vlink in the PATH.
  4. Go to the trunk's main directory and use the following command to build an FPC cross-compiler:
  make clean crossall crossinstall OS_TARGET=atari CPU_TARGET=m68k INSTALL_PREFIX="<path/to/install>"

If you've done everything right, you should find a working Atari cross-compiler in the install path you've specified.

Now, lets create a default fpc.cfg for Atari cross compiling. Create a file called <path/to/install>/lib/fpc/etc/fpc.cfg. Put the following lines into that file, and fix up the paths:

#IFDEF CPUM68K
-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET
-Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET/*
#IFDEF ATARI
-FD</path/to/atari-cross-binutils>
-XV
#ENDIF
#ENDIF

Optionally add <path/to/install>/lib/fpc/3.1.1/ directory to the PATH, so you'll have direct access to the cross-compiler. If you've done everything right, you now should be able to build Atari executables:

ppcross68k -Tatari <source.pas>