[fpc-devel] FPC for Coldfire and 68K derivatives

Sven Barth pascaldragon at googlemail.com
Fri Feb 15 11:45:07 CET 2013


Am 15.02.2013 08:39 schrieb "Mike Salish" <mike at avantisys.com>:
>
> It was interesting to see renewed activity in the compiler for the 68K
architecture. I've been using another old compiler, written in Pascal, for
embedded development for many years and been wanting to give FPC a try. My
existing compiler emits assembler for the 68K and CPU32 but lacks the
features that FPC can provide.
>
> I have been able to compile my existing compiler using FPC on a PC and
find that the resulting code is about 10% bigger (and slower) than the same
program compiled in Delphi. The good news is that when the FPC-compiled old
Pascal compiler is used to compile a big (20KLOC) Pascal embedded program
it produces exactly the same output. So as far as I am concerned this makes
the FPC a very viable tool. All that is missing is the 68K code generator
and RTL and... a few more bits.
>
> The work that has been done to be able to compile 68000/020..040 code is
admirable for completeness but of little practical value since it is
difficult to find hardware. At the moment the 68K versions still in
production are all for control applications in embedded systems. These
chips use the CPU32 and more recently the MCF5xxxx Coldfire architecture.
For MCF there are some sources of small and cheap demo boards (netgear,
Arcturus  I know of). IMO Coldfire is the only viable path for future
development that can see any practical use. And I think MCF code should run
on the CPU32 as well even though it will not use all the addressing modes
of the CPU32.

As I'm the one who did most of the recent work on m68k I'm the one that
definitely needs to answer you.

While I agree that no old style m68k CPUs are produced anymore there are
still people that use them. We have e.g. a core developer that has an old
Amiga. Also testing on different variations of the CPU might improve the
generated code in the long run (at least this is my hope).
Nevertheless I'm currently mostly working on Coldfire support. I'm mainly
using QEMU's user space emulation on Linux which emulates a Coldfire V4e.
But I also have a M54451evb with a MCF54451 and I also plan to purchase a
M54455evb board.
I'm trying though not to use ISA B and ISA C instructions in the compiler
until I've split current "coldfire" type into the three different ISAs.

>
> I've downloaded the compiler sources and would ask that anyone who can
provide the build strings and other tricks they have used to build a
cross-compiler targeting the 68K/CF point me in the right direction. I've
got the Build FAQ and Programmers Manual so I'm reading a lot.
>

I'm currently only working on m68k-linux, so I can't tell whether
m68k-embedded would work, but you should be able to build it as follows
inside the top level directory of the source (you need to use FPC 2.6.0 as
starting compiler and preferably have it in PATH, otherwise look at the
BuildFAQ):

make all CPU_TARGET=m68k OS_TARGET=embedded BINUTILSPREFIX=m68k-whatever-
CROSS_OPT="-O- -Cpcoldfire"

"m68k-whatever-" is the prefix of your cross binutils (as and ld).

If that should fail you could try "make cycle" with the same options inside
the compiler directory instead of "make all" in the top level directory.

When using the generated compiler (it will be called ppcross68k) you need
to pass at least the following arguments:
-Tembedded -XPm68k-whatever- -O- -Cpcoldfire -Fupath/to/compiled/rtl/units

The compiled units are normally located in $fpcsrc/rtl/units/m68k-embedded.

> I would like to build up a tool set that will produce assembler so that
it can be analyzed for correctness before I try to run it on real hardware.
I'm working in XP with Mingw, can work in OsX easily and in Linux with more
effort (don't have a machine setup for Linux now). For me I have embedded
emulator tools that work in XP so that would be my preferred path.

It might be necessary to add support for your specific hardware boards
first. I'm not experienced enough with our embedded target yet... I could
try to add support for my M54451evb as an example, but only starting in
March, as I'm currently preparing for and writing exams.

Please also keep in mind that the m68k code generator is highly in
development and while simple programs work already there are still enough
things that fail and maybe code generator bugs that hide other bugs... So
your mileage may vary... (and as you can see with the passed parameters
optimizations are not yet working/tested either)

Please keep me informed about any progress you make :)

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130215/fded0d34/attachment.html>


More information about the fpc-devel mailing list