Re: system constants in COBOL
- From: John Santos <john@xxxxxxx>
- Date: Fri, 16 Nov 2007 01:50:53 GMT
Tom Linden wrote:
On Thu, 15 Nov 2007 14:38:20 -0800, Hein RMS van den Heuvel <heinvandenheuvel@xxxxxxxxx> wrote:
On Nov 15, 3:23 pm, "Tom Linden" <t...@xxxxxxxxxxxxxx> wrote:
On Thu, 15 Nov 2007 11:25:58 -0800, Hein RMS van den Heuvel
> You gotta give the compiler a chance to optimize those constant,
> By using a linker resolved reference the compilers options are severly
> hed back imho.
Huh? Unless I misunderstood the constants are dealt with by the parser
and never get to the linker.
But that's exactly my point. It should be the parser seeing the
numeric values
and the cobol optimizer to do the right thing.
So this Cobol does not have the concept of include statements with replace
constants? That is lame. If done correctly it should never even get to
the optimizer.
Of course it does. All it needs is something to include that defines the
constants. Which doesn't exist. D'oh!
But these lame cobol programs stick it into an '88' and let the linker
fill in the value.
That will increase the code size slightly (notably for values like 0
and 1, less so for RMS$_FNF)
What is worse the extra code will be a memory reference.
Here is sample generated code (source below)
8 01 RETURN-STATUS PIC S9(09) COMP.
9 88 SYS$_NORMAL VALUE IS EXTERNAL SS$_NORMAL.
10 88 SYS__NORMAL VALUE IS 1.
11 88 RMS$_FNF VALUE IS EXTERNAL RMS$_FNF.
12 88 RMS__FNF VALUE IS 98962.
13 01 X PIC S9(9) COMP.
14 PROCEDURE DIVISION.
15 P0. CALL "TEST" GIVING RETURN-STATUS.
16 IF SYS$_NORMAL THEN MOVE 123 to X.
17 IF SYS__NORMAL THEN MOVE 345 to X.
18 IF RMS$_FNF THEN MOVE 567 to X.
19 IF RMS__FNF THEN MOVE 789 to X.
:
JSR R26, TEST
LDQ R1, 56(R2) ; 000016
MOV 123, R17
LDL R16, (R1)
XOR RETURN-STATUS, R16, R16
BNE R16, L$1
STL R17, -8(R3)
L$1:
XOR RETURN-STATUS, 1, R19 ; 000017
BNE R19, L$3
MOV 345, R20
STL R20, -8(R3)
L$3:
LDL R1, -4(R1) ; 000018
XOR RETURN-STATUS, R1, R1
BNE R1, L$5
MOV 567, R22
STL R22, -8(R3)
L$5:
LDAH R24, 2(R31) ; 000019
MOV 789, R25
LDA R24, -32110(R24)
XOR RETURN-STATUS, R24, R0
BNE R0, L$7
STL R25, -8(R3)
L$7:
LDQ R26, 96(R2) ; 000020
See the straight 1 in XOR for line 17?
Compare that with the LDQ R1, 56(R2) to fetch SS$_NORMAL !
For FNF as a literal it uses: LDA R24, -32110(R24)
So that is also NOT a memory reference, but a clever instruction.
Specially for SS$_NORMAL it is ludicrous to have the linker fill it
in.
An insult to the injury of not just doing an BLBS ("IF SUCCES")
Cheers,
Hein van den Heuvel
HvdH Performance Consulting
IDENTIFICATION DIVISION.
PROGRAM-ID. LNM.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 IO$_READVBLK PIC S9(09) COMP VALUE IS EXTERNAL IO$_READVBLK.
01 RETURN-STATUS PIC S9(09) COMP.
88 SYS$_NORMAL VALUE IS EXTERNAL SS$_NORMAL.
88 SYS__NORMAL VALUE IS 1.
88 RMS$_FNF VALUE IS EXTERNAL RMS$_FNF.
88 RMS__FNF VALUE IS 98962.
01 X PIC S9(9) COMP.
PROCEDURE DIVISION.
P0. CALL "TEST" GIVING RETURN-STATUS.
IF SYS$_NORMAL THEN MOVE 123 to X.
IF SYS__NORMAL THEN MOVE 345 to X.
IF RMS$_FNF THEN MOVE 567 to X.
IF RMS__FNF THEN MOVE 789 to X.
DISPLAY X.
END PROGRAM LNM.
--
John Santos
Evans Griffiths & Hart, Inc.
781-861-0670 ext 539
.
- References:
- Re: system constants in COBOL
- From: Hein RMS van den Heuvel
- Re: system constants in COBOL
- From: Bob Koehler
- Re: system constants in COBOL
- From: Hein RMS van den Heuvel
- Re: system constants in COBOL
- From: Tom Linden
- Re: system constants in COBOL
- From: Hein RMS van den Heuvel
- Re: system constants in COBOL
- From: Tom Linden
- Re: system constants in COBOL
- Prev by Date: Re: system constants in COBOL
- Next by Date: The NBA and VMS
- Previous by thread: Re: system constants in COBOL
- Next by thread: Re: system constants in COBOL
- Index(es):
Relevant Pages
|