QL / PASCAL

Anything QL Software or Programming Related.
User avatar
NormanDunbar
Forum Moderator
Posts: 1604
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: QL / PASCAL

Postby NormanDunbar » Wed May 12, 2021 5:10 pm

Another patch to the Free Pascal stuff.

FPC.patch.8.zip
(3.71 KiB) Downloaded 13 times


In this one, I have modified the qdos unit to:

  • Include a file qdos_sysvars.inc which has a new record type, SystemVariables, and a pointer to it, PSystemVariables.
  • Remove the existing offsets from the base of the system variables, superceeded by the above.

I've also modified Chain-Q's example, mtinf.pas, so that it uses the PSystemVariables type received from a call to MT_INF, and then prints some examples using the record type, rather than a lot of type casting from byte pointers (pbyte) to the actual data type of the system variables printed in his example.

If you apply this patch, then you will need to rebuild the QL Units as described in Section 12 of my afore mentioned (way above) document, then compile your example programs. But here's a reminder:

Code: Select all

cd ~/SourceCode/fpc
make packages_clean OS_TARGET=sinclairql CPU_TARGET=m68k
make packages RELEASE=1 FPC=fpc-ql OS_TARGET=sinclairql CPU_TARGET=m68k


We then need to install into the correct location:

Code: Select all

cd ~/bin/lib/fpc/3.3.1/units/m68k-sinclairql/qlunits
cp ~/SourceCode/fpc/packages/qlunits/units/m68k-sinclairql/* ./


The above assumes you are using the same source and binary locations as my document, and that you have renamed/sym-linked the cross compiler to be accessed as 'fpc-ql'.

I'm in the process of sorting a similar system variables record type for the SMS unit, but for some reason, it doesn't want to play just now. I'm working on it. Mind you, the SMS uint is pretty sparse right now.



Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
Derek_Stewart
Font of All Knowledge
Posts: 2353
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: QL / PASCAL

Postby Derek_Stewart » Fri May 14, 2021 5:41 pm

pjw wrote:(* I dont know about Q68, it only emulates a 68000, but sports a 32 bit bus..)

The Q68 does not have an emulated CPU, has the 68000 CPU written in FPGA code, coukd be considered to be a real CPU and runs the operating system natively.

I look forward to having a Pascal compiler that will run on my Q68.

I wonder if I port GIT to the QL, could I do away with Windows/Linux...


Regards,

Derek
User avatar
pjw
Aurora
Posts: 862
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QL / PASCAL

Postby pjw » Sat May 15, 2021 11:19 am

Derek_Stewart wrote:
pjw wrote:(* I dont know about Q68, it only emulates a 68000, but sports a 32 bit bus..)

The Q68 does not have an emulated CPU, has the 68000 CPU written in FPGA code, coukd be considered to be a real CPU and runs the operating system natively.<>

Perhaps thats a matter for the philosophers to ponder. Since the FPGA is not a 68k CPU it must perforce just be a simulation..?

But it doesnt answer my question: Does it behave like a 68020+ wrt addressing modes?


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
Derek_Stewart
Font of All Knowledge
Posts: 2353
Joined: Mon Dec 20, 2010 11:40 am
Location: Runcorn, Cheshire, UK

Re: QL / PASCAL

Postby Derek_Stewart » Sat May 15, 2021 1:50 pm

pjw wrote:
Derek_Stewart wrote:
pjw wrote:(* I dont know about Q68, it only emulates a 68000, but sports a 32 bit bus..)

The Q68 does not have an emulated CPU, has the 68000 CPU written in FPGA code, coukd be considered to be a real CPU and runs the operating system natively.<>

Perhaps thats a matter for the philosophers to ponder. Since the FPGA is not a 68k CPU it must perforce just be a simulation..?

But it doesnt answer my question: Does it behave like a 68020+ wrt addressing modes?


Hi Per,

Not a philosopher type question, but it was stated to me by the author, that the Q68 implements the 68000 CPU and does not emulate the 68000 CPU.

I would guess that there is no 68020 op codes in the Q68 FPGA core, so it only does 68000, not a great problem, as there is not many software that take advantage of 68020 CPU.

I faced the same issue in 2002 with the Q60, I wanted to have all 68060 code in the Q60, but there is no software and everyone is still using 68000 software.


Regards,

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

Re: QL / PASCAL

Postby NormanDunbar » Sat May 15, 2021 4:27 pm

Back onto the Pascal topic! ;)

I've updated the "How to" document with the following changes:

  • The bits about the linker error message have been removed as Chain-Q has fixed that.
  • I've added a section on how to create a new unit and, if necessary, a new example for same;
  • I've added a section on updating the version control (Subversion) so that it will look at your new files when creating a patch file.

Version 1.4 of the document is here: https://github.com/NormanDunbar/FPC-Cro ... ses/latest.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890
User avatar
Peter
QL Wafer Drive
Posts: 1295
Joined: Sat Jan 22, 2011 8:47 am

Re: QL / PASCAL

Postby Peter » Sat May 15, 2021 4:48 pm

pjw wrote:Perhaps thats a matter for the philosophers to ponder. Since the FPGA is not a 68k CPU it must perforce just be a simulation..?

No, not at all. The Q68 does not perform any kind of simulation or emulation. The 68k CPU is there in hardware. Instantly, when you power-on.
To understand this, it might help to think of PAL/GAL, which are just much simpler examples of programmable logic circuits.
You can not say a PAL/GAL emulates or simulates it's logic. It is programmed, and then it has the logic. Same here.
You could desolder the Q68 FPGA and it would still keep its 68k CPU, just like a 68K microcontroller from Motorola!
(I even had two business inquiries for the Q68 chip as a 68k microcontroller for non-QL purposes. Which made some sense, as it was more suitable than the last Motorola 68k microcontrollers for their applications. But too much documentation work for me and beyond my hobbyist goals. It rarely makes sense to still use 68k commercially.)

pjw wrote:But it doesnt answer my question: Does it behave like a 68020+ wrt addressing modes?

It does not. However, the funny thing is the logic could be changed to 68020 quite easily. (Not my achievement but of Tobias Gubener.) This was just not released, because the Q68 is a compromise for retro computing and the 68020 introduces a few incompatibilities for ancient software. One might only implement the extra adressing modes, wide multiplication etc., but not the stack frame. That would be a strange beast though.

Sorry for the off-topic reply, just wanted to clarify.


User avatar
pjw
Aurora
Posts: 862
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QL / PASCAL

Postby pjw » Sat May 15, 2021 6:09 pm

Hi Derek,

Thanks for your reply.
Derek_Stewart wrote:I faced the same issue in 2002 with the Q60, I wanted to have all 68060 code in the Q60, but there is no software and everyone is still using 68000 software.
As with all these things, I think that once the facility is there it will get used. 68060 code and capabilities may be a step too far, not least because the CPUs are hard to come by, but 68020 seems doable..

I can understand that there may be reluctance to employ capabilities that cannot be used on as many platforms as possible. But if the QL-philosophy is to progress there must come a time to leave the old behind.

Here on this thread there is talk of OO Pascal that is not suitable for older platforms. I say: Bring it on! And while we're at it, leave the old 68000 behind too, 'cause then we can, perhaps, look to other improvements.

There is no point in being reticent so as to bring the retro-fans - who I feel are the majority here - along: They are happy! They already have everything they need!

But enough of that under this heading!


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
pjw
Aurora
Posts: 862
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QL / PASCAL

Postby pjw » Sat May 15, 2021 6:10 pm

Thanks, Peter. Most informative! Might we see a Q68/20 some day? ;)


Per
Be wary of large West-Coast corporations bearing gifts!
- Ancient Trojan proverb
User avatar
M68008
Trump Card
Posts: 156
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: QL / PASCAL

Postby M68008 » Sat May 15, 2021 8:06 pm

pjw wrote:Perhaps thats a matter for the philosophers to ponder. Since the FPGA is not a 68k CPU it must perforce just be a simulation..?


Philosophical question indeed, as "emulator" can have a variety of meanings. The FPGA doesn't implement the same transistor layout and characteristics as the original Motorola chip, so I consider it a hardware emulation. Like a software emulation, it may be more or less accurate.
My understanding is that TG68K tries to emulate the behaviour of a 68K, but the internal architecture is relatively different. The FX68K FPGA core is much closer to the original architecture and even uses the same microcode as the original, but the low level hardware in a FPGA is still different from the original (e.g. different timing constraints).

Btw, the 68000 contains "microcode"!! So in a way there is a very simple software layer even inside the 68K! Apparently Motorola even had a version of the 68K with different microcode that was able to directly execute IBM 360 instructions. If you are curious, there is a long but interesting document here about the 68K history and design: https://www.youtube.com/watch?v=UaHtGf4aRLs

FPGA doesn't need a software simulation layer on top (although some boards like Mister also have an ARM processor and emulation of hardware like networking may be delegated to it) and offers primitives that are closer to the original hardware. For example, it's easier to accurately simulate the timing of hardware registers and video output, if one is interested in accurate simulation of the original QL hardware. Software emulation on a fast enough CPU can get similarly accurate for all practical purposes, but is less direct.

Perhaps a FPGA-implemented 68K CPU core can also be considered as a compatible CPU rather than an emulator.

For another point of view, it may be interesting to read the wikipedia article about emulators:
https://en.wikipedia.org/wiki/Emulator


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

Re: QL / PASCAL

Postby NormanDunbar » Sat May 15, 2021 10:11 pm

Evening all.

any chance you can take the emulator/68000/etc stuff to a new thread please? I keep seeing new posts on my (it's mine now even though I didn't start it) Pascal thread, only to find then off topic.

Much obliged, and apologies for being a grump. ;)

Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals - https://www.amazon.co.uk/Arduino-Softwa ... 1484257898, https://www.apress.com/gb/book/9781484257890

Who is online

Users browsing this forum: No registered users and 15 guests