QL / PASCAL

Anything QL Software or Programming Related.
Post Reply
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Post by mk79 »

Chain-Q wrote:
mk79 wrote:In any case, if it ever comes to that point I volunteer to have a look at porting vasm/vlink.
They're pretty much ANSI C with POSIX. So a sufficiently advanced libc and GCC 2.95.3 should be enough for it. Maybe. :) The only problem I see maybe is path handling differences, the QL seems to use the "_" character for paths, and I'm not sure if vlink has expectations about which character is the path separator or so.
Right. The whole directory business is the only real deficiency of QDOS based systems, as it was an afterthought implemented with backwards compatibility in mind :( Also, the maximum path length is severely limited for the same reason.
I'm sure Frank Wille, the author of vlink would be open to add a Sinclair QL target if it really comes to that. I'm in regular contact with him, and he's generally very open and helpful, and the QL binary format seems reasonably simple. In fact I already talked with him about this. But for now it wasn't needed. I use a custom linker script with vlink's "rawseg" mode, which combines .text (code) and .data and .bss sections into one using that linker script, then just writes two separate files with the the combined raw .text/.data (while omitting the zeroes for the .bss), and the relocation table for them.
Ah, I see. How is the relocation handled, is that in some startup code that is just linked in?

Cheers, Marcel


User avatar
Chain-Q
Chuggy Microdrive
Posts: 62
Joined: Mon Nov 16, 2020 1:10 pm
Location: Berlin, DE, EU
Contact:

Re: QL / PASCAL

Post by Chain-Q »

How is the relocation handled, is that in some startup code that is just linked in?
Yes, it's handled by the platform-specific system entry code, in the case of the QL it's here. The relocation table format is defined by vlink, but it's really simple, the first longword contains the number of relocations, and then each longword afterwards just contains a relocation offset.

BTW, last night I committed everything, so the QL target should be possible to build by anyone, but the runtime lib and the QL support units are still very basic. The If anyone feels like checking, the runtime library platform specific code is in /rtl/sinclairql, the support package is in /packages/qlunits/. If you look into sysfile.inc, sysdir.inc, etc, that's where the missing functions have to be implemented.

I'll add some simple build instructions to the FPC QL wiki page shortly.

Edit: Build instructions. These are quite standard for any FPC platform, but I added it anyway just to have a QL-specific quick reference.


User avatar
NormanDunbar
Forum Moderator
Posts: 2274
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Post by NormanDunbar »

If anyone needs a free (legal) Free Pascal book, Jeff Duntemann's "Free Pascal from Square One" is here http://www.copperwood.com/pub/FreePasca ... areOne.pdf.

I've had it for some time and it's good. Once he gets past the history stuff, but some people like that sort of thing.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Post by mk79 »

Chain-Q wrote:Edit: Build instructions. These are quite standard for any FPC platform, but I added it anyway just to have a QL-specific quick reference.
Good thinking ;) Additionally to the steps vasm must apparently be named "sinclairql-vasmm68k_std" and vlink "sinclairql-ld". With that I almost got it to work:

Code: Select all

ppcross68k -Tsinclairql test.pas
Free Pascal Compiler version 3.3.1 [2020/11/19] for m68k
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Sinclair QL
Compiling test.pas
Assembling test
Linking test.bin
Fatal error 11: link47317.res: File format not recognized.
Aborting.
test.pas(4,16) Error: Error while linking
test.pas(4,16) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Any idea why the linker script is not recognised?

Cheers, Marcel


User avatar
genetika
Over Heated PSU
Posts: 127
Joined: Thu May 05, 2011 5:38 pm
Location: Rome, ITALY
Contact:

Re: QL / PASCAL

Post by genetika »

Hi.
Sorry, but I don't understand.
Could I use the FPC compiler directly on QDOS environment, or i need to use it on Windows / MAC and cross-compile to QDOS.

Thanks!
M.


User avatar
NormanDunbar
Forum Moderator
Posts: 2274
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Post by NormanDunbar »

You would cross compile on Mac/Linux/Windows to build executables for the QL.

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
User avatar
Chain-Q
Chuggy Microdrive
Posts: 62
Joined: Mon Nov 16, 2020 1:10 pm
Location: Berlin, DE, EU
Contact:

Re: QL / PASCAL

Post by Chain-Q »

First, sorry for the delayed response. Near holiday season are busy days at work. There's always more stuff to finish this year...
mk79 wrote:Additionally to the steps vasm must apparently be named "sinclairql-vasmm68k_std" and vlink "sinclairql-ld".
Hmm, thanks for reporting this. I think the best would be to name the binaries with the "m68k-sinclairql-" prefix, this way you don't even have to specify BINUTILSPREFIX= for the make lines. But then you have to add an extra "-XPm68k-sinclairql-" argument to the fpc.cfg file. I adjusted the documentation accordingly. (To be honest, I build on my system slightly differently, but I can't recommend that to "end users", so this is why the doc wasn't 100% correct first, so thanks for the report.)
With that I almost got it to work:

Code: Select all

Fatal error 11: link47317.res: File format not recognized.
Aborting.
test.pas(4,16) Error: Error while linking
Any idea why the linker script is not recognised?
To be honest, no idea. Classic case of worksforme(tm). It almost looks like vlink thinks that your linker script should be an object file somehow? Very weird. Do you have any whitespace character in your path where you build by any chance? Also, which vlink version do you use? I guess you're building on Windows, is the vlink binary self-built, or you just found some binaries online? I know vlink could behave strange ways on Windows sometimes, but this is still a weird problem.


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Post by mk79 »

Chain-Q wrote:First, sorry for the delayed response. Near holiday season are busy days at work. There's always more stuff to finish this year...
Don't worry, no hurry on my side.
To be honest, no idea. Classic case of worksforme(tm). It almost looks like vlink thinks that your linker script should be an object file somehow? Very weird.
OK, just thought I ask before spending time on it.
Also, which vlink version do you use?

Code: Select all

~ marcel$ sinclairql-ld -v
vlink V0.16f (c)1997-2020 by Frank Wille
build date: Nov 19 2020, 13:53:13

Standard library path:
Default target: amigahunk
Supported targets: amigahunk amigaehf ataritos xfile os9-6809 elf32ppcbe elf32powerup elf32morphos elf32amigaos elf32m68k elf32i386 elf32aros elf32armle elf32jag elf64x86 aoutnull aoutsun010 aoutsun020 aoutbsd68k aoutbsd68k4k aoutmint aoutbsdi386 aoutpc386 aoutjaguar vobj-le vobj-be rawbin1 rawbin2 amsdos applebin ataricom cbmprg cbmreu cocoml dragonbin jagsrv srec19 srec28 srec37 ihex oilhex rawseg
I guess you're building on Windows, is the vlink binary self-built, or you just found some binaries online?
No, I have one headless Mac server that I sometimes use for Unixy stuff. Build from source.

Cheers, Marcel


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Post by mk79 »

Chain-Q wrote:To be honest, no idea. Classic case of worksforme(tm). It almost looks like vlink thinks that your linker script should be an object file somehow? Very weird. Do you have any whitespace character in your path where you build by any chance? Also, which vlink version do you use? I guess you're building on Windows, is the vlink binary self-built, or you just found some binaries online? I know vlink could behave strange ways on Windows sometimes, but this is still a weird problem.
Just a quick update, I already found it curious that the linker was names "sinclairql-ld" instead of "sinclairql-vlink" and that is the reason.

Code: Select all

UseVLink:=(cs_link_vlink in current_settings.globalswitches);
evaluates to false, so it tries to call LD with a different command line. Can you tell me how to activate this switch?


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QL / PASCAL

Post by mk79 »

OK, to answer myself, it's "ppcross68k -Tsinclairql -XV test.pas" (the "-XV" is the magic switch). What does the Basic loader do then, I can't seem to find it anywhere?


Post Reply