[fpc-devel] Porting FPC to IBM zArch
bernd.oppolzer at t-online.de
Wed Jul 24 03:41:37 CEST 2013
I'm a new member on the fpc-devel mailing list.
I would like to know, if there are still some efforts going on to
do a port of FPC on IBMs z architecture. There has been some work
in this area, although somewhere in the FPC wiki there are statements
that there will be probably no port to IBM z.
Anyway, I would like to do some work on this. In 2011, I ported an extended
version of the Stanford compiler (the McGill version from 1982, with some
maintenance done in 2007) from MUSIC/SP to VM/370 R6 on Hercules
- an IBM 370 emulator - and then I did some extensions to it, including new
language elements (new statements break, continue, return and new
comment styles, some 2-byte char representations that VS/PASCAL had,
for example -> for the pointer symbol etc.) and I fixed some
When trying to port this compiler to OS/2 and Linux, I observed some
set problems. I didn't complete this due to limited time.
Today I ported a pretty print tool which is part of this environment
using FPC on Windows. The only issue was that the scanner had to be
because on Windows it reads the linend characters 0x0d and 0x0a, where
IBM mainframe there are no lineend characters (the runtime sends blanks
Pascal program at line end).
Another issue is the character set: in the EBCDIC case there are gaps
the alphabetic characters, so you have to code - for example:
if ch in (. 'A' .. 'I', 'J' .. 'R', 'S' .. 'Z' .) then begin ... end;
but this works for an ASCII based compiler as well.
I looked at fpc/compiler/scanner.pas and saw some source parts using
ch in (. 'A' .. 'Z' .)
which should be changed to a function call like isupper (ch) etc,
where the dependencies of the underlying character set should be handled,
but IMO there are not many places where the compiler is really dependent of
the character set.
My roadmap is:
- first I would like to port the Stanford compiler to Windows, OS/2 and
maybe Linux 386,
using FPC. Only phase 1, which generates PCode. My goal is not to get a
which produces executable code, but to learn about the issues when
porting an EBCDIC
compiler to an ASCII machine, in the first place. This is of course much
easier than the
other direction (FPC to zArch), because the compiler is much smaller.
- when I completed this, I would like to experiment with FPC, trying to
build a compiler
from the source tree, for a new target CPU and OS, that is, IBMZ. I know
IBM machine code, ASSEMBLER, opsys and run time systems. In contrast to
that I saw already (targetting zLinux with ASCII codebase), I plan to
build a FPC compiler
which works on BOTH codebases - I want to know, where the issues are.
There are some minor problems I faced when compiling the Stanford Pascal
sources with FPC:
- Stanford Pascal (my version) allows (. .) and (/ /) as substitutes for [ ]
- and -> for the pointer symbol (like VS/PASCAL)
- and different styles of comments:
(* ... *)
/* ... */
and - strange to me, but it's in the compiler source: "this is a
Comments of different types can be nested;
comments of the same type can be nested, if the compiler option N+ is set.
The new statements break, continue and return were also present in
and they work much the same way as their C counterparts. Because I added
them in 2011,
they are of course not present in the compiler source.
What do you think of those extensions?
If you would, for example, accept one or more of those suggestions, I
would enjoy helping
you to implement those extensions in FPC, once I got more insights in
the internal structure
of the compiler (in some months or so).
If you want, you can contact me offline, to discuss some details further.
My native language is German.
More information about the fpc-devel