QL / PASCAL

Anything QL Software or Programming Related.
Post Reply
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 »

Yes, actually, there was a piece of uncommitted code, which made vlink default for the Sinclair QL. This was in my working copy, but somehow I missed to commit it, which explains my confusion, because it indeed worked for me... Sorry. See here. So if you update the source and rebuild, you'll no longer need -XV when building for the QL.

Anyway, the build will generate a few files. Say, for example if you build hello.pas, these files will be generated:

* hello - the BASIC loader. The source which generates it is in compiler/systems/t_sinclairql.pas
* hello.bin - the actual "final" binary
* hello.bin.hdr - the linker "header" info, which will contain a list of generated sections (only one in this case) it's start address and length (including the omitted bss section)
* hello.bin.main - the code + data section of the binary
* hello.bin.main.relmain - the relocation table


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 »

I have a slightly off-topic question, but it's related because I need it for another example program. :) Is there a tool (preferably one which can run on a non-QL computer for cross-compiling) which can convert a GIF or BMP or something to the native QL screen format? Maybe with dithering, etc... Before I start writing one... :) Not like that wouldn't be a fun project, I just have enough fun projects already :P


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 »

Code: Select all

program test;

uses qdos;

procedure PrintStr(ch: longint; const s: shortstring);
begin
  io_sstrg(ch,-1,@s[1],ord(s[0]));
end;

begin
  PrintStr(stdOutputHandle, 'Hello world');
end.
hello_world.png
hello_world.png (1.83 KiB) Viewed 2091 times
Yay :-P When I find the time I might try to implement EXE support. Of course the real work will be in the libraries... :?


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

Re: QL / PASCAL

Post by NormanDunbar »

Nice one Marcel.


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
Ruptor
Gold Card
Posts: 418
Joined: Fri Dec 20, 2019 2:23 pm
Location: London

Re: QL / PASCAL

Post by Ruptor »

NormanDunbar wrote:Nice one Marcel.
Yes but I suppose the next step is size & speed comparison to a native pascal compiler output.


User avatar
BSJR
Trump Card
Posts: 182
Joined: Sun Oct 18, 2015 12:53 pm
Location: Amsterdam
Contact:

Re: QL / PASCAL

Post by BSJR »

Chain-Q wrote:I have a slightly off-topic question, but it's related because I need it for another example program. :) Is there a tool (preferably one which can run on a non-QL computer for cross-compiling) which can convert a GIF or BMP or something to the native QL screen format? Maybe with dithering, etc... Before I start writing one... :) Not like that wouldn't be a fun project, I just have enough fun projects already :P
There is a small program that does GIF to QL mode 4 or 8 with dithering:
http://www.dilwyn.me.uk/graphics/ungif.zip
On the same page there are more conversion programs but most may need more memory and/or SMSQ/E.

BSJR


User avatar
Andrew
Aurora
Posts: 786
Joined: Tue Jul 17, 2018 9:10 pm

Re: QL / PASCAL

Post by Andrew »

http://www.dilwyn.me.uk/graphics/bmp2pic.zip
Bmp2pic - a Windows program from Phoebus R. Dokos to convert Windows BMP files to QL screens. It probably nees and older windows version, not windows 10.


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 »

Ruptor wrote:Yes but I suppose the next step is size & speed comparison to a native pascal compiler output.
Just to manage some expectations... :) When it comes to comparing to the old compilers, the code which FPC generates will be almost certainly bigger, and on the original '008 almost certainly be slower. Why? Well, there are a few reasons.

* Free Pascal is a multi-platform compiler, which means its libraries contain additional abstraction layers, which lead to some code bloat. Our slogan is "write once, compile anywhere", and our own code respects that philosophy too. :)

* Free Pascal's m68k backend was tuned for 020+ CPUs, and while it does support the '000, for example the ALU size is assumed to be 32 bit for all 68k currently, just as the default integer size is always 32 bit. The compiler has no infrastructure to easily redefine the expected ALU size between various members of the same architecture (for example on Intel, i8086 and i386+ are treated as totally different architectures). Also, according to experience on other platforms, Free Pascal will be used to bring "modern" code to the legacy platform, and most of the "modern" Pascal code expects 32bit integers as default. So the current way offers more compatibility, but this means the compiled code will be inherently less optimal for a '000, and perform better on more advanced members of the 68k family.

* Free Pascal also supports more features than old Pascal compilers, has an intelligent internal memory manager, has more convenient I/O features, has support for heap allocated strings with "unlimited" length, there's of course the mentioned OOP, software exception handling, even support for stuff like string codepage conversion and Unicode, has an optional "SoftFPU", so it can work with IEEE floating point numbers even if the hardware has no FPU, etc, etc. But all of this adds code and "bloat". It's possible to strip out some of this, or technically it's even possible to build a library from scratch for the original QL if needed, to make it as lean as possible, but if you want that, you're probably on your own. :) Nothing stops you though, as everything is open source and can be added or modified as needed.

To make an example, on Amiga, a simple "hello, world!" example can be up to 30K. And at this point then everyone will scream out in horror, why is that, I can write an assembly hello world in 30 bytes!... Or my C compiler will do it in 2K! But after most of the infrastructure for the features detailed above is there and included, it's possible to build applications like this, which I wrote to talk to some old PC boards in Amiga. The actual executable of this application is less than 64K, and it has okay performance when it comes to rendering/emulating CGA PC graphics into an Amiga window... (And this app is 100% Pascal code, no assembly for performance critical parts.)

So I guess this sums it up, more or less.
Last edited by Chain-Q on Sun Nov 22, 2020 2:36 pm, edited 1 time in total.


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 »

mk79 wrote:Yay :-P When I find the time I might try to implement EXE support. Of course the real work will be in the libraries... :?
Congrats for being the 2nd person who ever managed to get this shebang somewhat working. :) BTW, in the currently committed version, I think a simple Pascal-ish writeln('Hello, World!') should work to, no need to specify a QL-specific PrintStr() function. I know that was my initial example on Twitter, but that was before I wired up at least some bits of the stardard I/O support and console init.

Edit: also thanks to others who recommended the bitmap converters, will check them out.


User avatar
Ruptor
Gold Card
Posts: 418
Joined: Fri Dec 20, 2019 2:23 pm
Location: London

Re: QL / PASCAL

Post by Ruptor »

Chain-Q wrote:So I guess this sums it up, more or less.
Thanks for the heads up that essentially says more not less. :lol: Again it raises the same question that I asked when joining this forum "what is the point in QL maintenance?" but it seems people like bus man's holidays and a change is as good as a rest. I love Lazarus & FPC that enables me, a low level assembler & C programmer, to do high level programs where I wouldn't stand a chance using C++. 30K for Hello World that is half the microdrive capacity is funny and if it keeps up minimum programs will be 10 Gig although 30K does still leave 98K on the QL ram free. :lol:


Post Reply