QL / PASCAL
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Thanks Chain-Q. I'm reading in bed at the moment (insomnia) but I'll give your fixes/workarounds a proper try soon, and get back to you.
Cheers,
Norm.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Ha! Sneaky. At least I still have my uses!mk79 wrote:Au contraire, I had exactly the same problems, but I thought I leave something for you to figure out, too So well done
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Font of All Knowledge
- Posts: 3932
- Joined: Mon Dec 20, 2010 11:40 am
- Location: Sunny Runcorn, Cheshire, UK
Re: QL / PASCAL
HI,
I compiled FPC on a Debian 10 Linux Core i7 Laptop, which compiled OK.
I find Lazarus a little complicated to use, but I suppose a little configuration if maybe be simple to use. I have used Eclipse, which looks the same as Lazarus.
Personally, I prefer to write source code in a text editor and compile from the command line, which FPC allows.
I have not got the Sinclair QL output code running yet, but it is just a matter of understanding the well written help pages.
I think overall FPC is an excellent Pascal compiler,I would mainly use it on Linux to write Pascal programmes.
I have subscribed to the FPC mailing list, so I may pop up there once I have more experience in FPC.
I compiled FPC on a Debian 10 Linux Core i7 Laptop, which compiled OK.
I find Lazarus a little complicated to use, but I suppose a little configuration if maybe be simple to use. I have used Eclipse, which looks the same as Lazarus.
Personally, I prefer to write source code in a text editor and compile from the command line, which FPC allows.
I have not got the Sinclair QL output code running yet, but it is just a matter of understanding the well written help pages.
I think overall FPC is an excellent Pascal compiler,I would mainly use it on Linux to write Pascal programmes.
I have subscribed to the FPC mailing list, so I may pop up there once I have more experience in FPC.
Regards,
Derek
Derek
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Most helpful, but highly unlikely I'll be moving things around. Good to know though.Chain-Q wrote: You can actually extend environment variables inside fpc.cfg. So you can replace /home/norman with $HOME$ (note the trailing $) and it will work. Minor thing, but if you move your config files around in several systems, it might help.
Hmmm:Chain-Q wrote:The reason for this is because 8+3 filenames support is enabled for the Sinclair QL, because I based the system descriptor table inside the compiler on the Atari TOS version... And this leads to some inconsistencies if the compiler and the external build process prefers "m68k-sinclairql" or just "sinclairql" as the full name of the target. As a workaround, I changed this in the wiki now, to recommend $fpccpu-$fpcos combination, instead of $fpctarget. This works for now. (I actually tested it now... )
Code: Select all
$ cat ~/fpc-ql/lib/fpc/etc/fpc.cfg
#IFDEF CPUM68K
-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/$fpccpu-$fpcos
-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/$fpccpu-$fpcos/*
-Tsinclairql
#IFDEF SINCLAIRQL
-FD/home/norman/bin
-XPm68k-sinclairql-
-WQxtcc
#ENDIF
#ENDIF
Code: Select all
$ fpc-ql test.pas
Fatal: Can't find unit system used by test
Fatal: Compilation aborted
I honestly don't mind. The QL allows up to 36 characters in a file name, plus 5 more for the device, 8.3 was always a bit limited, even on DOS 3.x! The best answer is probably "what is the standard with other implementations? Do they all get the "CPU-OS" format? If so, stick with "m68k-sinclairql" otherwise, "sinclairql" says it all.Chain-Q wrote:Having said this, what do you think? Should the compiler/build system stick to the shorter version of "sinclairql" or use "m68k-sinclairql" everywhere? The later would require switching the 8+3 short filenames support, but it doesn't really make a difference for now, because the native compiler is still quite far away (if it ever happens), but it would be good to make it consistent at least. I'd prefer the longer version, for consistency with other systems (where no 8+3 unless required), but I also don't have a really strong preference.
Right, let's debug:Chain-Q wrote:Another hint: Debugging config file and path issues is quite easy using the -vv compiler argument. This will write a file called "fpcdebug.txt" into the current directory, which contains human readable verbose information about the config file parsing, telling you what it expands those $foobar templates into, and if it can find the path or not.
Code: Select all
$ fpc-ql -vv test.pas
Fatal: Can't find unit system used by test
Fatal: Compilation aborted
Code: Select all
$view fpcdebug.txt
...
00020000:Handling option "-Fu/home/norman/fpc-ql/lib/fpc/3.3.1/units/m68k-linux"
...
00008000:Path "/usr/lib/fpc/3.3.1/units/sinclairql/rtl/" not found
...
00008000:Compiler: /home/norman/fpc-ql/lib/fpc/3.3.1/ppcross68k
00020000:Compiler OS: Linux for x86-64
00001000:Target OS: Sinclair QL
...
10000001:Fatal: Can't find unit system used by test
10000001:Fatal: Compilation aborted
Thanks for all your hard work. Hopefully, I'll be able to contribute something in return.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- Chain-Q
- Chuggy Microdrive
- Posts: 62
- Joined: Mon Nov 16, 2020 1:10 pm
- Location: Berlin, DE, EU
- Contact:
Re: QL / PASCAL
Sorry, I wasn't too precise. You have to put -Tsinclairql before any line where these config variables/templates related to the target are resolved. So -Tsinclairql has to be before the -Fu lines. The config file is just resolved/parsed in a linear sequence, and the default target for cross compilers is usually Linux (see below). Hence the -Fu line before -Tsinclairql, which actually switches the target over to the QL will resolve the $fpcos to "linux".NormanDunbar wrote: It's unfortunately, still not working for me. I'll see what the debugger says.
It's nothing to do with your host system, as I wrote, the cross-compilers just tend to default to Linux, because most often that's the target platform we use for compiler testing. The cross-compiler binary itself is OS target agnostic. It can compile for any m68k target. Obviously the native compilers default to their host platforms.NormanDunbar wrote:It's picked up my host operating system, linux, and not the one I'm cross-compiling for, sinclairql.
Hope this helps.
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Ha! Of course, that makes a whole lot of sense when you put it like that! Call it a "senior" moment!Chain-Q wrote:Sorry, I wasn't too precise. You have to put -Tsinclairql before any line where these config variables/templates related to the target are resolved.
This config file:
Code: Select all
#IFDEF CPUM68K
-Tsinclairql
-Fu/home/norman/fpc-ql/lib/fpc/$fpcversion/units/$fpccpu-$fpcos
-Fu/home/norman/fpc-ql/lib/fpc/$fpcversion/units/$fpccpu-$fpcos/*
#IFDEF SINCLAIRQL
-FD/home/norman/bin
-XPm68k-sinclairql-
-WQxtcc
#ENDIF
#ENDIF
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
I thought I would have a quick look at adding to the RTL for the Sinclair QL Free Pascal Cross Compiler.
I checked out the latest "trunk" source code, and found the RTL in rtl/sinclairql. So far so good.
I first had to build the current cross compiler, just to be sure everything was hunky dory before I started messsing with code:
I have not installed it yet as I already have it build and installed. I may overwrite my current installation when it all works with my changes.
Now I can start editing code .....
Looking through sysfile.inc for something to do, I noticed that the Pascal erase function was missing. This deletes a file given its name. Should be simple enough.
In sysfile.inc I added changed the empty handler to this:
In qdosfuncs.inc, I added this line:
In qdos.inc I added this const with the other file handling consts:
then, added this code to do the actual deletion, givem a QL formatted string as the file name:
And, finally, this to convert from a Pascal string to a QL String, to call the above:
To compile the above changes, I assumed (oops!) that all I would need to do would be to run make in the rtl/sinclairql directory:
That doesn't appear to work and gives the following messages:
If I go back to the "trunk" directory, and clean the whole lot and rebuild, it (appears) to work -- but I have yet to test if my changes have been included. If I don't do a clean first, it completes without appearing to do anything at all.
Surely there's a (better) way to rebuild just the system unit for a cross compiler? Has anyone tried? The readme in the rtl directory says In principle, you can also descend into the subdirectory of your OS, and type 'make' there, that should also compile everything. That also fails:
Cheers,
Norm.
I checked out the latest "trunk" source code, and found the RTL in rtl/sinclairql. So far so good.
I first had to build the current cross compiler, just to be sure everything was hunky dory before I started messsing with code:
Code: Select all
make clean OS_TARGET=sinclairql CPU_TARGET=m68k
make crossall OS_TARGET=sinclairql CPU_TARGET=m68k
Now I can start editing code .....
Looking through sysfile.inc for something to do, I noticed that the Pascal erase function was missing. This deletes a file given its name. Should be simple enough.
In sysfile.inc I added changed the empty handler to this:
Code: Select all
{ delete a file, given its name}
procedure do_erase(p : pchar; pchangeable: boolean);
begin
Error2InOutRes(io_delet(p));
end;
Code: Select all
function io_delet(name: pchar): longint; external name '_io_delet';
In qdos.inc I added this const with the other file handling consts:
Code: Select all
_IO_DELET = $04;
Code: Select all
function io_delet_qlstr(name_qlstr: pointer): longint; assembler; nostackframe; public name '_io_delet_qlstr';
asm
movem.l d2-d3,-(sp)
move.l name_qlstr,a0
moveq.l #-1,d1
moveq.l #_IO_DELET,d0
trap #2
tst.l d0
@quit:
movem.l (sp)+,d2-d3
end;
Code: Select all
function io_delet(name: pchar): Tchanid; public name '_io_delet';
var
len: longint;
name_qlstr: array[0..63] of char;
begin
len:=length(name);
if len > length(name_qlstr)-2 then
len:=length(name_qlstr)-2;
PWord(@name_qlstr)[0]:=len;
Move(name^,name_qlstr[2],len);
result:=io_delet_qlstr(@name_qlstr);
end;
Code: Select all
cd rtl/sinclairql
make OS_TARGET=sinclairql CPU_TARGET=m68k
Code: Select all
-XPm68k-sinclairql- -Fi../inc -Fi../m68k -Fim68k -FE. -FU../../rtl/units/m68k-sinclairql -dm68k -Us -Sg @rtl.cfg system.pp
Error: ppc68k can't be executed, error message: Failed to execute "ppc68k", error code: 127
make: *** [Makefile:3570: system.ppu] Error 1
Surely there's a (better) way to rebuild just the system unit for a cross compiler? Has anyone tried? The readme in the rtl directory says In principle, you can also descend into the subdirectory of your OS, and type 'make' there, that should also compile everything. That also fails:
Code: Select all
make: -iVSPTPSOTO: Command not found
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- mk79
- QL Wafer Drive
- Posts: 1349
- Joined: Sun Feb 02, 2014 10:54 am
- Location: Esslingen/Germany
- Contact:
Re: QL / PASCAL
Hi Norm,
thanks for trying, I don't have enough time at the moment. But I just tried it, too. I don't understand the build process much, but looking at the full build process I was able to distill two lines (execute in main Dir):
I'm running out of time, so the install process must wait for now. But probably it's enough to copy one or two files over.
Cheers, Marcel
thanks for trying, I don't have enough time at the moment. But I just tried it, too. I don't understand the build process much, but looking at the full build process I was able to distill two lines (execute in main Dir):
Code: Select all
make rtl_cleanall
make rtl_all FPC=<path-to-fpc>/compiler/ppcross68k FPMAKE=<path-to-fpc>/compiler/ppc RELEASE=1 OPT= FPCMAKEOPT= OS_TARGET=sinclairql CPU_TARGET=m68k BINUTILSPREFIX=
Cheers, Marcel
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Thanks Marcel, I'll give that a try later. Housework to do today. Yuk!
Cheers,
Norm.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
- NormanDunbar
- Forum Moderator
- Posts: 2251
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: QL / PASCAL
Progress report. (Or lack therof!)
This worked for me and my changes were compiled:
I have ppcross68k on my PATH so I don't need the full path. I also have it symlinked to fpc-ql. This bit is confusing though:
As I don't appear to have a ppc file on my PATH anywhere, in the cross compiler or in the host compiler directories. I've used the locate and find commands, and found nothing.
So, things compile ok and when I look at the new system.ppu and system.o unit with the strings command, I can see that my new functions are found. Or at least listed as being there. So far so good.
Before moving the newly compiled units (system.o and system.ppu) I tested a small compile:
It compiles fine, provided that I do not have the "PROGRAM ..." line in it. FPC says that this is optional, but if it is present, it refuses to compile and gives me the error ". expected but '(' found at line " with the final line listed. This is for a host compile. Removing the line compiles happily. Weird?
So, my source is in "~/SourceCode/fpc" and my cross compiled stuff is in "~/bin", so a quick copy of "system.o" and "system.ppu" from "~/SourceCode/fpc/trl/units/m68k-sinclairql" to "~/bin/lib/fpc/3.3.1/units/m68k-sinclairql/rtl" goes fine.
Now when I try to cross compile, I get lots of errors. I can only get rid if I copy over everything!
I did experiment and find a make target of "rtl_install"
Unfortunately, it errors out.
Right, back to the test of my erase function. When copied over to QPC, it runs, prints up the message that the file will be deleted, but then barfs with runtime error 103. In order to get it to run without error I have to change the source to this:
And, that runs perfectly without any runtime errors, but doesn't delete the test.txt file (all on RAM1_). So, I need to do a bit more testing usingthe full file name (ram1_test.txt" and/or checking that the file test.txt is deleted from wherever my defaults are pointing!
Cheers,
Norm.
This worked for me and my changes were compiled:
Code: Select all
make rtl_cleanall
make rtl_all FPC=ppcross68k RELEASE=1 OS_TARGET=sinclairql CPU_TARGET=m68k
Code: Select all
FPMAKE=<path-to-fpc>/compiler/ppc
So, things compile ok and when I look at the new system.ppu and system.o unit with the strings command, I can see that my new functions are found. Or at least listed as being there. So far so good.
Before moving the newly compiled units (system.o and system.ppu) I tested a small compile:
Code: Select all
{ Program to demonstrate the Erase function. }
Var F : Text;
begin
Assign(F,'test.txt');
Rewrite(F);
Writeln('The file, "test.txt" will be deleted.');
Writeln(F,'Try and find this when I''m finished !');
Close(F);
Erase(F);
end.
So, my source is in "~/SourceCode/fpc" and my cross compiled stuff is in "~/bin", so a quick copy of "system.o" and "system.ppu" from "~/SourceCode/fpc/trl/units/m68k-sinclairql" to "~/bin/lib/fpc/3.3.1/units/m68k-sinclairql/rtl" goes fine.
Now when I try to cross compile, I get lots of errors. I can only get rid if I copy over everything!
I did experiment and find a make target of "rtl_install"
Code: Select all
make rtl_install RELEASE=1 OS_TARGET=sinclairql CPU_TARGET=m68k INSTAL_PREFIX=/home/norman/bin
Right, back to the test of my erase function. When copied over to QPC, it runs, prints up the message that the file will be deleted, but then barfs with runtime error 103. In order to get it to run without error I have to change the source to this:
Code: Select all
{ Program to demonstrate the Erase function. }
Var F : Text;
begin
Writeln('The file, "test.txt" will be deleted.');
Assign(F,'test.txt');
Erase(F);
end.
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.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.