Difference between revisions of "ZSeries"

From Free Pascal wiki
Jump to navigationJump to search
m (Add "Architectural details" section for discussion from mailing list.)
(→‎Architectural details: Add links to discussion of EBCDIC vs ASCII etc.)
Line 31: Line 31:
  
 
== Architectural details ==
 
== Architectural details ==
 +
 +
This section is largely an archive of discussion in the fpc-devel mailing list, starting in January 2012.
 +
 
=== CPU capabilities ===
 
=== CPU capabilities ===
 
=== Target operating system ===
 
=== Target operating system ===
 +
 +
There are a number of operating systems freely available for this architecture:
 +
 +
* DOS/360 (DOS/VSE for S/370, EBCDIC)
 +
* OS/360 (now MVS for S/370, EBCDIC
 +
* MUSIC/SP (for S/370, EBCDIC)
 +
* VM/370 (for S/370, EBCDIC)
 +
* Linux (for zSeries, ASCII)
 +
 +
Any of these should run on the Hercules emulator, except that MUSIC/SP requires its own emulator (SIM/390) in order for TCP/IP to be available.
 +
 +
The OS/380 project [http://mvs380.sourceforge.net/] is attempting to enhance the Hercules emulator and the "classic" IBM operating systems above (DOS, OS and VM) to address more memory and possibly make additional facilities available. This is very much "work in progress" but appears to be the most organised maintenance attempt, as well as being a useful repository for obsolete binaries.
 +
 
=== Character set: ASCII vs EBCDIC ===
 
=== Character set: ASCII vs EBCDIC ===
 +
 +
The fact that the "classic" operating systems are EBCDIC-based is likely to cause difficulties, and might necessitate both work in the core compiler and a branch of the RTL. See for example [http://en.wikipedia.org/wiki/EBCDIC], noting that the sorting/capitalisation conventions that apply to ASCII are not applicable. See discussion at [http://lists.freepascal.org/lists/fpc-devel/2012-January/027992.html] [http://lists.freepascal.org/lists/fpc-devel/2012-January/028050.html] [http://lists.freepascal.org/lists/fpc-devel/2012-January/028174.html] plus lesser references in other threads from about the same time.
  
 
== Implementation status ==
 
== Implementation status ==

Revision as of 18:51, 8 February 2012

Overview

IBM uses the zSeries designation to indicate an implementation of the system architecture that includes the System/360 (1964), System/370 (1970), System/390 (1990) and others.

The zSeries CPU uses a proprietary CISC architecture unrelated to other processors such as the PowerPC which is used in IBM's iSeries (AS/400) and pSeries (RS/6000) systems. Note that these designations are basically marketing terms and as such are somewhat fluid.

The original S/360 architecture had 32-bit integer registers and a 24-bit address space. This has been extended first to support a 31-bit address space and later to support 64-bit registers and address space. In addition many models support paged/expanded memory.

In the 1990s Linux was ported onto the S/390, almost invariably running as a guest/virtualised operating system in the context of a "traditional" host OS. In addition GCC was ported, the paper below discussing some of the problems that were encountered.

Porting GCC to the IBM S/390 Platform

Notable points from this paper are that older versions of the S/390 and its predecessors had two significant limitations that were tolerable when the systems were programmed in assembler but caused significant problems for automatic code generation:

  • Literals had to be in tables rather than inline. Tables were limited to 4K.
  • There were no PC-relative jumps.

These limitations were likely to be particularly severe if a compiler was translating machine-generated source, where functions/procedures might be very large.

More recent versions of the S/390, probably the G3 manufactured after September 1996, enhance the 32-bit instruction set to allow inline literals and PC-relative jumps. These restrictions do not exist on more recent implementations of the architecture, e.g. the 64-bit zSeries systems, note that GCC v4 and Linux 2.6 appear to assume that the hardware is at least G5 i.e. no older than 2000.

It is possible to simulate a 32- or 64-bit system using the Hercules emulator, and IBM makes machine time available to developers porting code to their systems.

Installing Debian under Hercules

Community development system

An Assembler Programmer's view of Linux for S/390 and zSeries

Whether this is relevant to FPC/Lazarus is arguable since the architecture is already supported on Linux by GCC Pascal, Pascal-XSC, and on other operating systems (as a commercial product) by at least IBM Pascal/VS and/or VS Pascal. Paul Robinson (see below) also points out that Lazarus might be irrelevant on this platform since many facilities provided as standard on PCs and workstations have no counterpart on "classic" IBM operating systems.

Architectural details

This section is largely an archive of discussion in the fpc-devel mailing list, starting in January 2012.

CPU capabilities

Target operating system

There are a number of operating systems freely available for this architecture:

  • DOS/360 (DOS/VSE for S/370, EBCDIC)
  • OS/360 (now MVS for S/370, EBCDIC
  • MUSIC/SP (for S/370, EBCDIC)
  • VM/370 (for S/370, EBCDIC)
  • Linux (for zSeries, ASCII)

Any of these should run on the Hercules emulator, except that MUSIC/SP requires its own emulator (SIM/390) in order for TCP/IP to be available.

The OS/380 project [1] is attempting to enhance the Hercules emulator and the "classic" IBM operating systems above (DOS, OS and VM) to address more memory and possibly make additional facilities available. This is very much "work in progress" but appears to be the most organised maintenance attempt, as well as being a useful repository for obsolete binaries.

Character set: ASCII vs EBCDIC

The fact that the "classic" operating systems are EBCDIC-based is likely to cause difficulties, and might necessitate both work in the core compiler and a branch of the RTL. See for example [2], noting that the sorting/capitalisation conventions that apply to ASCII are not applicable. See discussion at [3] [4] [5] plus lesser references in other threads from about the same time.

Implementation status

Paul Robinson, Lead Programmer and Chief Cook and Bottle Washer for Viridian Development Corporation is creating a cross-compiler for this architecture, and is documenting in real time what's involved. There is a link to his current work at the bottom of this document.

Refer to discussion threads in the fpc-devel mailing list [6] which includes discussion of the desirability of this port (unanimously agreed to be a good idea), selection of target hardware and operating system, and problems which might be caused by the EBCDIC character set used by older IBM mainframe operating systems. Also refer to Qemu and other emulators#Debian zSeries Guest using Hercules, without VM for discussion of running zSeries Linux on a PC using the Hercules emulator.

Some of the problems with e.g. limitations on inline literals can potentially be gotten around by careful use of registers in the code. (You can get around most problems if you have spare registers). There are trade-offs: basically registers 3-12 are available for any use; each register can address up to 4K of code or data; you can use multiple registers to index to the particular portion provided you don't need to manipulate any chunk of data exceeding 4K at a time. One possibility is to use some registers for code and some for data, by moving up from 3 for either code or for data, and moving down from 12 for the other. If it's not too big in both directions, you should be okay.

Nevertheless, one possible use of doing a cross-compiler using Free Pascal for the 370/390/zSystem is to provide a reference on how to do so for other potential architectures. As noted above, Paul Robinson is doing a cross-compiler for the zSeries using Free Pascal and is explaining how he's going about it as he does so. An introduction begins with Part 1 and goes from there.