Difference between revisions of "Sinclair QL"

From Free Pascal wiki
(Added simple build instructions.)
(restructured assembler and linker sections, added licensing)
 
(7 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
==Stack==
 
==Stack==
  
The default stack size is set to 8 KiB, which is quite small for a Pascal program. For more complex programs you'll probably need to increase this.
+
The default stack size is set to 8 KiB, which is quite small for a Pascal program. For more complex programs you'll probably need to increase it. To change the stack size, use the '''{SMEMORY <stacksize>,<heapsize>}''' directive, or the '''-Cs''' command line argument. See the details in the documentation.
  
 
==CPU==
 
==CPU==
  
The default CPU target for the Sinclair QL is the 68000. This is different from most other [[m68k]] targets where the default is the 68020.
+
The default CPU target for the Sinclair QL is the 68000. This is different from most other [[m68k]] targets where the default is the 68020. The SoftFPU is enabled by default for the QL.
  
 
==Alignment==
 
==Alignment==
Line 23: Line 23:
 
Record elements are aligned to WORD (2 bytes) on the Sinclair QL by default. Use the '''{$PACKRECORDS n}''' compiler directive, if you want to change the default aligment. For byte aligned records, a packed record is also possible. Free Pascal also has support for 68000/68008 [[m68k#Unaligned access support|special alignment requirements]].
 
Record elements are aligned to WORD (2 bytes) on the Sinclair QL by default. Use the '''{$PACKRECORDS n}''' compiler directive, if you want to change the default aligment. For byte aligned records, a packed record is also possible. Free Pascal also has support for 68000/68008 [[m68k#Unaligned access support|special alignment requirements]].
  
==Assembler==
+
==External Dependencies==
 +
 
 +
The Sinclair QL port depends on '''vasm''' and '''vlink''', as external assembler and linker.
 +
 
 +
===Assembler===
  
 
The only supported assembler for the Sinclair QL port is '''vasm''', which is also the default. The Sinclair QL uses the '''vasm'''-specific ''.vobj'' object format. This means using '''vasm''' also requires '''vlink''' as [[#Linker|linker]]. '''vasm''' is open source, and it is available [http://sun.hasenbraten.de/vasm here]. Only '''vasm''' versions 1.8 and newer were tested with the Sinclair QL port, older versions might not work.
 
The only supported assembler for the Sinclair QL port is '''vasm''', which is also the default. The Sinclair QL uses the '''vasm'''-specific ''.vobj'' object format. This means using '''vasm''' also requires '''vlink''' as [[#Linker|linker]]. '''vasm''' is open source, and it is available [http://sun.hasenbraten.de/vasm here]. Only '''vasm''' versions 1.8 and newer were tested with the Sinclair QL port, older versions might not work.
Line 37: Line 41:
 
The resulting ''vasmm68k_std'' executable file is the assembler Free Pascal needs.
 
The resulting ''vasmm68k_std'' executable file is the assembler Free Pascal needs.
  
==Linker==
+
===Linker===
  
 
The Sinclair QL ports defaults to '''vlink''' by Frank Wille as the default linker, which is the only supported linker as well for this target. '''vlink''' is open source, and it is available [http://sun.hasenbraten.de/vlink here].
 
The Sinclair QL ports defaults to '''vlink''' by Frank Wille as the default linker, which is the only supported linker as well for this target. '''vlink''' is open source, and it is available [http://sun.hasenbraten.de/vlink here].
  
 
Please make sure you use '''vlink''' version 0.16c or newer. Earlier versions were not tested with Free Pascal and the Sinclair QL target.
 
Please make sure you use '''vlink''' version 0.16c or newer. Earlier versions were not tested with Free Pascal and the Sinclair QL target.
 +
 +
===Licensing===
 +
 +
Please note that the license of '''vasm''' and '''vlink''' does not allow development of commercial applications. If you plan to develop and sell a commercial application using these tools, you need their author's written consent. Please see the documentation of [http://sun.hasenbraten.de/vasm/release/vasm.html vasm] and [http://sun.hasenbraten.de/vlink/release/vlink.pdf vlink] for details.
  
 
==Building==
 
==Building==
Line 49: Line 57:
 
# Install the latest stable FPC version for your host platform. This will be used as the startup compiler.
 
# Install the latest stable FPC version for your host platform. This will be used as the startup compiler.
 
# Check out FPC SVN trunk into a directory.
 
# Check out FPC SVN trunk into a directory.
# Make sure you have the binaries '''vasmm68k_std''' and '''vlink''' in the '''PATH'''. ''(See above.)''
+
# Make sure you have the binaries '''vasmm68k_std''' and '''vlink''' in the '''PATH'''. ''(See above.)'' Their binaries must be named (or symlinked) as '''m68k-sinclairql-vasmm68k_std''' and '''m68k-sinclairql-vlink'''.
 
# Go to the trunk's main directory and execute the following commands:
 
# Go to the trunk's main directory and execute the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
   make clean OS_TARGET=sinclairql CPU_TARGET=m68k
 
   make clean OS_TARGET=sinclairql CPU_TARGET=m68k
   make crossall OS_TARGET=sinclairql CPU_TARGET=m68k BINUTILSPREFIX=
+
   make crossall OS_TARGET=sinclairql CPU_TARGET=m68k
   make crossinstall OS_TARGET=sinclairql CPU_TARGET=m68k BINUTILSPREFIX= INSTALL_PREFIX="<path/to/install>"
+
   make crossinstall OS_TARGET=sinclairql CPU_TARGET=m68k INSTALL_PREFIX="<path/to/install>"
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 63: Line 71:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
  #IFDEF CPUM68K
 
  #IFDEF CPUM68K
  -Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET
+
  -Fu<path/to/install>/lib/fpc/$fpcversion/units/$fpccpu-$fpcos
  -Fu<path/to/install>/lib/fpc/$fpcversion/units/$FPCTARGET/*
+
  -Fu<path/to/install>/lib/fpc/$fpcversion/units/$fpccpu-$fpcos/*
 
  #IFDEF SINCLAIRQL
 
  #IFDEF SINCLAIRQL
 
  -FD</path/to/vasm-and-vlink>
 
  -FD</path/to/vasm-and-vlink>
 +
-XPm68k-sinclairql-
 
  #ENDIF
 
  #ENDIF
 
  #ENDIF
 
  #ENDIF
Line 77: Line 86:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
If the Sinclair QL is the only target you want to target for m68k with this config file, you may want to add the option '''-Tsinclairql''' into the config file as well, just make sure you add it as the first argument, right after '''#IFDEF CPUM68K'''.
 +
 +
==Compiler Arguments==
 +
 +
The Sinclair QL port has a few platform specific compiler command line arguments.
 +
 +
===Setting metadata format===
 +
 +
Using the '''-WQ<x>''' argument it's possible to set the generated metadata style for the executable, to either Q-emuLator/QPC v5 compatible "QDOS File Header" style or to XTcc style, which can be used by SMSQmulator, InfoZIP and various other tools:
 +
 +
      -WQ<x>    Set executable metadata format (Sinclair QL)
 +
        -WQqhdr    Set metadata to QDOS File Header style (default)
 +
        -WQxtcc    Set metadata to XTcc style
 +
 +
The default is "qhdr", and doesn't need to be explicitly specified.
  
 
[[Category:Operating Systems and Platforms]]
 
[[Category:Operating Systems and Platforms]]

Latest revision as of 01:05, 14 December 2020

The Sinclair QL or QDOS port is an experimental "just for fun" m68k target. It targets the Sinclair QL line of computers from the mid-80s, and their operating system QDOS. This port is currently a cross-compiler only target. This is mostly due to hardware limitations of the original unexpanded platform. Later QL clones could run the compiler in theory, however, there are no plans to support these due to their extreme rarity.

The QL port was implemented by Karoly Balogh during #QLvember 2020, when various online retro communities and YouTubers were running Sinclair QL related projects.

Requirements

The compiled binaries - depending on the size - should be able to run on any Sinclair QL. Memory expansion for more complex programs is highly recommended.

Identification

To identify the Sinclair QL compile-time, use {$IFDEF SINCLAIRQL}.

Stack

The default stack size is set to 8 KiB, which is quite small for a Pascal program. For more complex programs you'll probably need to increase it. To change the stack size, use the {SMEMORY <stacksize>,<heapsize>} directive, or the -Cs command line argument. See the details in the documentation.

CPU

The default CPU target for the Sinclair QL is the 68000. This is different from most other m68k targets where the default is the 68020. The SoftFPU is enabled by default for the QL.

Alignment

Record elements are aligned to WORD (2 bytes) on the Sinclair QL by default. Use the {$PACKRECORDS n} compiler directive, if you want to change the default aligment. For byte aligned records, a packed record is also possible. Free Pascal also has support for 68000/68008 special alignment requirements.

External Dependencies

The Sinclair QL port depends on vasm and vlink, as external assembler and linker.

Assembler

The only supported assembler for the Sinclair QL port is vasm, which is also the default. The Sinclair QL uses the vasm-specific .vobj object format. This means using vasm also requires vlink as linker. vasm is open source, and it is available here. Only vasm versions 1.8 and newer were tested with the Sinclair QL port, older versions might not work.

Building vasm

Note that vasm for m68k needs to be built with the standard syntax module to work with Free Pascal. This is not the default, as most programmers and compilers prefer the Motorola syntax module. A vasm version with the standard syntax module can be built with the following command, issued in the root of the vasm source tree:

 make CPU=m68k SYNTAX=std

The resulting vasmm68k_std executable file is the assembler Free Pascal needs.

Linker

The Sinclair QL ports defaults to vlink by Frank Wille as the default linker, which is the only supported linker as well for this target. vlink is open source, and it is available here.

Please make sure you use vlink version 0.16c or newer. Earlier versions were not tested with Free Pascal and the Sinclair QL target.

Licensing

Please note that the license of vasm and vlink does not allow development of commercial applications. If you plan to develop and sell a commercial application using these tools, you need their author's written consent. Please see the documentation of vasm and vlink for details.

Building

To build a Sinclair QL cross-compiler, follow these steps:

  1. Install the latest stable FPC version for your host platform. This will be used as the startup compiler.
  2. Check out FPC SVN trunk into a directory.
  3. Make sure you have the binaries vasmm68k_std and vlink in the PATH. (See above.) Their binaries must be named (or symlinked) as m68k-sinclairql-vasmm68k_std and m68k-sinclairql-vlink.
  4. Go to the trunk's main directory and execute the following commands:
  make clean OS_TARGET=sinclairql CPU_TARGET=m68k
  make crossall OS_TARGET=sinclairql CPU_TARGET=m68k
  make crossinstall OS_TARGET=sinclairql CPU_TARGET=m68k INSTALL_PREFIX="<path/to/install>"

If you did everything right, you will find a working Sinclair QL cross-compiler with the pre-built RTL and Packages units in the install path you've specified. If you plan to rebuild FPC often, you might want to put the above commands in a script for easy rebuilding.

Now, lets create a default fpc.cfg for Sinclair QL cross compiling. Create a file called <path/to/install>/lib/fpc/etc/fpc.cfg. (Note: this is the path on Unix systems. Free Pascal on other platforms might expect a different path.) Put the following lines into that file, and fix up the paths:

 #IFDEF CPUM68K
 -Fu<path/to/install>/lib/fpc/$fpcversion/units/$fpccpu-$fpcos
 -Fu<path/to/install>/lib/fpc/$fpcversion/units/$fpccpu-$fpcos/*
 #IFDEF SINCLAIRQL
 -FD</path/to/vasm-and-vlink>
 -XPm68k-sinclairql-
 #ENDIF
 #ENDIF

Optionally add <path/to/install>/lib/fpc/3.3.1/ directory to the PATH, so you'll have direct access to the cross-compiler. (Note: this is the path on Unix systems. Free Pascal on other platforms the ppcross68k compiler binary might be in a different path.) If everything went right, you now should be able to build Sinclair QL executables with:

 ppcross68k -Tsinclairql <source.pas>

If the Sinclair QL is the only target you want to target for m68k with this config file, you may want to add the option -Tsinclairql into the config file as well, just make sure you add it as the first argument, right after #IFDEF CPUM68K.

Compiler Arguments

The Sinclair QL port has a few platform specific compiler command line arguments.

Setting metadata format

Using the -WQ<x> argument it's possible to set the generated metadata style for the executable, to either Q-emuLator/QPC v5 compatible "QDOS File Header" style or to XTcc style, which can be used by SMSQmulator, InfoZIP and various other tools:

     -WQ<x>     Set executable metadata format (Sinclair QL)
        -WQqhdr    Set metadata to QDOS File Header style (default)
        -WQxtcc    Set metadata to XTcc style

The default is "qhdr", and doesn't need to be explicitly specified.