[fpc-devel] Inline Constants (was On a port of Free Pascal to the IBM 370)
steve smithers
stevie at collector.org
Mon Jan 30 18:29:04 CET 2012
I have just found the thread discussing a port of FreePascal to the System/370
and I feel I have to correct some misinterpretations, mistakes and other
calumnies that have been thrown into the discussion. First, my qualifications.
I have been a developer of Assembler systems, both applications and systems
software since 1981. I have worked on VS1, MVS (370, XA, ESA), OS/390 and
Z/OS systems. I have worked for many large blue chip companies and for
software house (small) and computer manufacturer's (large).
Episode 2. Inline constants
Firstly, let me explain that there are two different points regarding what has
been called "literal" values as concerns S/370 architecture and it's Assemblers.
The first of these is called "immediate" values where the literal is included
in the actual code generated for that instruction. The second are called
"Literals" and describe unnamed constants that are defined on the instruction
that uses them in the source code, but resolve to storage areas that are built
into the object deck later.
The "Porting GCC to System/390" document in section 3.1 referred to and other
posts state "the original S/390 architecture did not provide instructions that
could use literal values as immediate operands". This is untrue. Since the
System/360 was introduced there was a class of instructions called SI (Storage
Immediate) that allowed just that. The values were however, limited to 1 byte.
This has applied to it's descendents (370, 370/XA 390, ESA z/OS and z/OS 64)
The 390 extensions in the mid 1990's defined new instructions and extensions to
increase this limit to 2 bytes and later to 4 bytes, perhaps, beyond. I've
never worked on the latest 64bit machines so I can't comment.
An example of SI instruction use.
Code Source Comments
92C1 C024 MVI FIELD,C'A' Move character A to field.
A728 0009 LHI R2,H'9' Load 9 into register 2 Note H is a
halfword or 16 bit integer value
The code generated is 92C1,C024 where 92 is the opcode, C1 is the character 'A'
and C024 is the address in standard base/displacement form. Or A7 is the
opcode, 28 specifies a 32bit load into R2 0009 is the value to load into the
register. LHI is S/390 and later.
An equivalent example of literal instruction use.
D200 C024 C136 MVC FIELD,=C'A' Move character A to field.
4820 C134 LH R2,=H'9' Load 9 into register 2 Note H is a
halfword or 16 bit integer value
The code generated is D200,C024,C136 where D2 is the opcode, C024 is the
address of FIELD and C136 the address of the literal, both in standard
base/displacement form. The 00 is data regarding the length of data to move
limited from 1 to 256 bytes in this case. Or 48 is the opcode, 20 specifies
the target register (R2) and the optional index register (unused) C134 is the
address of the 16 bit value to load in base/displacement form. Where are the
constants? Well they are generated automatically at the end of the module, or
if you wish to define them elsewhere you can include a "LTORG" statement which
tells the assembler to define them.
What I would like to know is "Why is this a problem?" So the constants are
defined elsewhere, what issues does this raise?
More information about the fpc-devel
mailing list