A2C - IT-Modernisation

Download Report

Transcript A2C - IT-Modernisation

Assembler to COBOL
The fully automated transformation using TRAVERT®.A2C
Explained along the example of a complete, executable assembler program
© 2008 – 2015 Schierholz IT Modernisation GmbH
January 14, 2015
Introduction Simple Patterns Complex Patterns Synopsis
Contents
Introduction
Simple patterns
Handling comments
Storage definitions
Relative jumps
Transformation of code-molecules.
Here: B/NOP, UNPK/OI, Field Padding with MVI/MVC, EX, ED/EDMK
Complex and highly complex patterns
Resolving the OS Linkage Convention
Files: definition and access
Detection and transformation of subroutines
Tables: definition and access
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
2
Introduction Simple Patterns Complex Patterns Synopsis
The company Products The demo program
The company
Schierholz IT Modernisation GmbH is the expert in
automated processing of computer languages
Areas of application
Analysis of software systems of any complexity and size
Transformation of languages into any other
- without any change of functionality
Reengineering of source code in arbitrary languages
Our customers are large IT users (mostly using mainframes), most of all insurances,
banks and authorities.
Our services
Significant cost reduction of the IT by migration (as a rule at over 50% !)
Best possible preparation of projects by a complete and thourough analysis of historically
grown systems: consistency, redundancy, missing code, dependency from third party
systems and so forth.
Data is being shown in graphic representation and/or handed out as a repository.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
3
Introduction Simple Patterns Complex Patterns Synopsis
The company Products The demo program
Products
RULAMAN® is the universal working platform for all of our products
SPL – our genuine programming language for a highly efficient development of
converters and analysis tools
YGGDRASIL® performs an automated analysis of software systems in any language,
magnitude or complexity
TRAVERT® products comprise several converters, e. g.
TRAVERT.A2C transforms mainframe assembler to ANSI-COBOL
TRAVERT.Ix2J converts Informix 4GL to Java
TRAVERT.V2R modernizes COBOL VSAM application and the data to Oracle or DB2
GRANUM® products are reengineering without leaving the language, e. g.:
GRANUM.RE – reengineering , restructuring, removing dead code and much more
GRANUM.FO – standardizes code formatting („Beautifying“)
GRANUM.RF – refactoring, also to position for a migration to Java or C#
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
4
Introduction Simple Patterns Complex Patterns Synopsis
The company Products The demo program
This Presentation ...
... shows the capabilities of our conversion products by the transformation of an
assembler program to COBOL using our product A2C.
We will explain the most important transformation aspects by comparing the
assembler origin with the corresponding result in COBOL.
The best thing is: Everything is done fully automated!
The resulting COBOL program works identically and error-free without any manual
post processing!
Before you are going into the details
we recommend that you download the accompanying material
and have it ready as a reference.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
5
Introduction Simple Patterns Complex Patterns Synopsis
The company Products The demo program
The Demo Program A2CP2
Input:
ZIP code,
requestor ID,
priority
AUTHTAB
ID, authority
name
A2CP2
checks and
completes the
read-in records
uses two
internal tables
CITYTAB
ZIP, city name,
inhabitants
Output:
Listing
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
6
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Simple Patterns
Handling comments
Storage definition
Relative jumps
Transformation of so-called code molecules
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
7
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Relocating the Program Description
***********************************************************************
* The program reads selected ZIP codes from a sequential file and
* enriches the data with related information from 2 internal tables.
. . .
*
authority ID, 4 bytes alphanumeric
*
authority name, 20 bytes alphanumeric
***********************************************************************
1.1
1.2
Per default A2C interprets the first larger block of full-line
comments as the program description.
This comment block is moved
to the beginning of the COBOL program.
PROGRAM-ID. A2CP2.
*
***********************************************************************
* The program reads selected ZIP codes from a sequential file and
* enriches the data with related information from 2 internal tables.
. . .
*
authority ID, 4 bytes alphanumeric
*
authority name, 20 bytes alphanumeric
***********************************************************************
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
8
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Inserting the Transformation History
A2C generates information
regarding the program
and the transformation process
directly behind the program description.
*----------------------------------------------------------------*
* Entity
A2CP2
* Transformed by Schierholz IT Modernisation GmbH
*
Baumwall 5, 20459 Hamburg, Germany
* On
12.12.2014 09:05:25
* Using
A2C Version 4.2
*
A2C is a RULAMAN(r) based product
* ---------------------------------------------------------------*
* Parameters
none
* ENTRY
none
* Calling
none
* Return code 0
* ABEND code
none
*----------------------------------------------------------------*
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
9
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Heading Blocks
***********************************************************************
* Print final statistics
***********************************************************************
PRTS14
DC
F'-1'
PRTSTATS DS
0H
8.2
Pattern matching has identified PRTSTATS
and other sequences as subroutines.
Now the comment block directly preceding »PRTS14«
can be moved
to the start of the COBOL representation of the subroutine.
***********************************************************************
* Print final statistics
***********************************************************************
PRTSTATS SECTION.
PRTSTATS-Start.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
10
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Dealing With Inline Comments
A2C offers 3 different options to deal with inline comments
1.
2.
3.
TRANSFORM – transforms inline comments into COBOL full-line comments, which can be placed either
before or after the related line
REMOVE – deletes inline comments
KEEP – transforms assembler inline comments into COBOL inline comments (*>)
In most of the situations option 2 »REMOVE« makes most
sense, because each assembler inline comment refers to
one particular statement.
A2C on the other hand transforms several assembler
statements into one single COBOL statement.
Hence option »REMOVE« has been activated for this
demonstration.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
11
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
A Relative Jump
CP
BL
AP
BAL
MVI
LINECNT,=P'50'
*+14
PAGECNT,=P'1'
R14,PRTHDR
INERR,X'00'
max 50 lines here
no header to be printed
5.1
print header line(s)
reset indicator
6.1
5.2
The »BL *+14« skips the »AP« and the »BAL«.
On the COBOL side we find a conditional »GO TO« leading to
a label which was created by A2C (»Demo-BT0«).
NB: the prefix, here: »Demo-« is of course freely selectable!
EVALUATE TRUE
WHEN LINECNT < 50
GO TO Demo-BT0
END-EVALUATE
ADD 1 TO PAGECNT
PERFORM PRTHDR.
Demo-BT0.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
12
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Location Counter and Storage Addresses
INREC
INZIP
INREQID
INPRI
DS
DS
DS
DS
DS
DS
ORG
0CL80
CL5
C
CL4
C
C
INREC+L'INREC
requesting authority
3
The length attribute »0« in »0CL80«
is transformed into a »FILLER REDEFINES«.
In this example the ORG-command is used to define a „gap“ in storage
whose length is calculated automatically by the assembler.
A2C performs that computation and generates the appropriate
»FILLER«.
01 INREC PIC X(80).
01 FILLER REDEFINES INREC.
02 INZIP PIC X(5).
02 FILLER PIC X.
02 INREQID PIC X(4).
02 FILLER PIC X.
02 INPRI PIC X.
02 FILLER PIC X(68).
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
13
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Code-Molecules
Several assembler statements which have a defined meaning in their entirety, are
referred to as „code molecules“
A2C’s pattern recognition knows a multitude of such molecules and activates the
corresponding transformation rules
The molecule is replaced
often by a single COBOL instruction
or an elegant COBOL construct
Frequently encountered molecules are
Self-modifying code, often a so-called B/NOP-switch
UNPK with a subsequent sign correction using an OI
MVI / MVC to initialize a whole field to one character
The EX-instruction with its attached statement-to-be-executed
ED / EDMK for the formatting of numeric fields.
In our example A2C creates different re-definitions related to the different ED-masks.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
14
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Example B/NOP
MAIN
NOP
MVI
PASS01
MAIN+1,X'F0'
next time no file OPEN
4.1
4.2
A2C replaces this molecule by a switch,
which is queried instead of the »NOP«.
MAIN.
IF SW-1-JUMP
GO TO PASS01
END-IF
SET SW-1-JUMP TO TRUE
The definition of the switch is generated automatically
into the WORKING STORAGE SECTION.
77 SW-1 PIC X VALUE 'N'.
88 SW-1-JUMP VALUE 'Y'.
88 SW-1-NO-JUMP VALUE 'N'.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
15
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Molecules UNPK/OI and Field Padding
UNPK/OI
UNPK
OI
HDR1PG,PAGECNT
HDR1PG+L'HDR1PG-1,X'F0'
9.1
9.2
A2C generates a „character numeric“ redefinition of »HDR1PG«.
02 HDR1PG-0ZL3 PIC 999.
Thereafter the molecule can be replaced by a single »MOVE«.
MOVE PAGECNT TO HDR1PG-0ZL3
Field Padding
MVI
MVC
DETAUTH,C'?'
DETAUTH+1(L'DETAUTH-1),DETAUTH
17.1
17.2
The so-called field padding is substituted by a simple »MOVE ALL«.
MOVE ALL '?' TO DETAUTH
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
16
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Molecule „EX“
PACK
CVB
BCTR
EX
DWD,INPRI
R2,DWD
R2,0
R2,MVCSTAR
MVCSTAR
MVC
10.4
10.5
10.1
Pattern recognition goes from the »PACK« down to the »EX« .
In addition the target instruction (here: an »MVC«)
is included in the pattern.
DETPRI(0),STARS
10.2
The sequence is replaced by a »MOVE« and a »SUBTRACT«.
The variable length, used by the EX, is transformed to a »MOVE« with
a „COBOL Reference Modifier”.
MOVE INPRI-0ZL1
MOVE DWD-0PL8
SUBTRACT 1
MOVE STARS
TO DWD-0PL8
TO Demo-R2Lo-S
FROM Demo-R2Lo
TO DETPRI(1:(Demo-R2Lo + 1))
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
17
Introduction Simple Patterns Complex Patterns Synopsis
Comments Addressing Rel. Jumps Code-Molecules
Molecule „ED/EDMK“
MVC
ED
DETINH,=X'402020206B2120206B202020'
DETINH,DWD+3
11.2
10.1
The editing pattern, moved here into the target field of the »ED«, serves
as a model for the COBOL definition to be created.
02 DETINH PIC BZZZ,Z99,999.
Having achieved this, a simple »MOVE«
is all we need to resolve the ED instruction.
MOVE DWD-3PL5
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
TO DETINH.
18
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Complex Patterns
Transforming the code of the OS Linkage Convention
Files: definition and data access
Detection and invocation of subroutines (BAL/BAS)
Transformation of table data and table access
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
19
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Transforming the OS Linkage Convention
SAVE
LR
USING
LA
ST
ST
LR
(14,12)
R12,R15
A2CP2,R12
R2,SAVEAREA
R2,8(R13)
R13,4(R2)
R13,R2
LA
R15,0
L
R13,4(R13)
RETURN (14,12),RC=(15)
2.1
get base address
link to next SA
link to prev SA
2.2
This is only one of numerous patterns and variants of the
program initialization.
The code is recognized and removed completely!
2.3
Caller's SA
2.4
This is a typical pattern for setting the return code
and returning to the caller.
This leads to the following COBOL code:
MOVE 0 TO RETURN−CODE
GOBACK.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
20
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
File Input and Output
The sample assembler program contains an input and an output file.
As a consequence (among others) the following statements must be transformed:
INFILE
INEND
OUTLST
DCB
BLKSIZE=80,LRECL=80,MACRF=GM,EODAD=INEND,DDNAME=INFILE, +14.5
DSORG=PS
DS
0H
end of input file reached
14.3
DCB
BLKSIZE=133,LRECL=133,MACRF=PM,RECFM=A,DDNAME=OUTLST,
+15.4
DSORG=PS
GET
INFILE,INREC
get first/next record
14.2
PUT
OUTLST,DETLINE
15.3
OPEN (INFILE,(INPUT))
14.1
OPEN (OUTLST,(OUTPUT))
15.1
CLOSE (INFILE)
14.4
CLOSE (OUTLST)
15.2
NB.: The demo program was written for z/OS. Of course A2C supports also the
macros of z/VSE and BS2000.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
21
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Files in COBOL
A2C transforms the assembler code dealing with files, for example into the following
statements:
FILE-CONTROL.
SELECT INFILE
ASSIGN TO S-INFILE
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS INFILE-STATUS.
. . .
FD INFILE
BLOCK CONTAINS 1 RECORDS
RECORD CONTAINS 80 CHARACTERS
RECORDING MODE IS F.
01 INFILE-RECORD PIC X(80).
. . .
77 INFILE-STATUS PIC XX.
77 OUTLST-STATUS PIC XX.
. . .
OPEN INPUT
INFILE
OPEN OUTPUT
OUTLST.
. . .
READ INFILE RECORD INTO INREC
AT END GO TO INEND
END-READ
© 2008-2015 Schierholz IT Modernisation GmbH
All the COBOL statements for defining and
accessing files can be found in the resulting
COBOL program.
They are created like everything else fully
automated by A2C.
Assembler to COBOL
22
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Subroutines
Many patterns are dealing with the recognition and transformation of subroutines.
The example contains subroutine invocation using the BAL instruction
Working registers must be identified
Statements to save and reload those working registers need to be determined. The related
instructions and data definitions must be eliminated.
The end of a subroutine must be identified, even if it has more than one “end”, i.e. several
exits.
All of the subroutine is moved into a common subroutine pool. It becomes a COBOL
SECTION and the BAL or BAS is replaced by a COBOL PERFORM.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
23
Introduction Simple Patterns Complex Patterns Synopsis
Rel. Jumps Subroutines Tables Files
Detecting and Transforming Subroutines
The »BAL«-instruction becomes a COBOL »PERFORM«.
The total routine is moved into the
so-called „A2C Subroutine Pool”.
BAL
R14,PRTHDR
PRTHDR
DS
F
DS
0H
ST
R14,*-4
. . .
L
R14,PRTHDR-4
BR
R14
print header line(s)
save R14
6.1
6.3
6.4
6.5
In the end we need only
3 COBOL statements as a replacement.
Customers tend to have their own methods to call
subroutines.
It is very easy to teach A2C any new kind of pattern.
PERFORM PRTHDR.
PRTHDR SECTION.
PRTHDR-Start.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
24
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Tables – One of The Most Complex Subjects
The patterns to detect tables and their related access instructions are extremely
complex. They form their own large set of rules within A2C.
Table recognition is parametrized, e. g. by a minimum number of rows or columns.
Tables become COBOL tables by
Definition of all the data rows
Redefinition of all of the table by an OCCURS clause
Automated generation of the table index and the table maximum
Table access mechanisms are recognized
Head-, foot- or counter-controlled loop
Programmed with BXH, BXLE, BCT or as ordinary loops with a jump back to top
Register addressing of cells or rows is transformed into an index-based access
End-of-table recognition using a delimiter, e.g. X‘FF‘ is supported, too.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
25
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Tables
The tables AUTHTAB and CITYTAB (lines 149 and 274)
are transformed to COBOL.
The result is shown in the COBOL source code
starting at line 147 and 178.
GET010
DS
LA
GETLOOP DS
CLI
BE
CLC
BE
LA
B
GETFD
DS
MVC
B
GETNOTFD DS
MVI
MVC
MVC
AP
MVI
GETEND
BR
0H
R3,AUTHTAB
0H
0(R3),X'FF'
GETNOTFD
not found
INREQID,0(R3)
GETFD
match!
R3,24(R3)
The access to »AUTHTAB« on the left can be found starting
GETLOOP
on line 176 in the assembler source code.
0H
DETAUTH,4(R3)
How A2C converts this logic fully automated into COBOL
GETEND
is shown on the next slide.
0H
DETAUTH,C'?'
DETAUTH+1(L'DETAUTH-1),DETAUTH
DETAUTH(L'INREQID),INREQID
ERRCNT,=P'1'
INERR,X'FF'
R14
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
26
Introduction Simple Patterns Complex Patterns Synopsis
Linkage Files Subroutines Tables
Tables
01 FILLER REDEFINES AuthTbl.
02 AUTHTAB-ENTRY OCCURS 7 INDEXED BY AuthTbl-Index.
03 AuthTbl-ID PIC X(4).
03 AuthTbl-Name PIC X(20).
Among other things A2C created the table index
»AuthTbl-Index« and
the definition of an indexed table row.
GET010.
SET AuthTbl-Index TO 1.
GETLOOP.
IF AuthTbl-Index > AuthTbl-Maximum
GO TO GETNOTFD
END-IF
EVALUATE TRUE
WHEN INREQID = AuthTbl-ID(AuthTbl-Index)
GO TO GETFD
END-EVALUATE
A2C transforms the assembler table access
SET AuthTbl-Index UP BY 1
(see preceding slide) fully automated
GO TO GETLOOP.
into the COBOL sequence
GETFD.
on the left.
MOVE AuthTbl-Name(AuthTbl-Index) TO DETAUTH
GO TO GETEND.
GETNOTFD.
MOVE ALL '?'
TO DETAUTH
MOVE INREQID
TO DETAUTH-0XL4
ADD 1
TO ERRCNT
MOVE HIGH-VALUE TO INERR.
GETEND.
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
27
Introduction Simple Patterns Complex Patterns Synopsis
Synopsis
The product TRAVERT®.A2C is capable of transforming mainframe-assemblerprograms fully automated into immediately correct COBOL programs.
We would love to explain how this works, how assembler conversion projects are
carried out and what needs to be considered.
Please do not hesitate to call +49 40 524 7058 - 10.
Further information on our products and services can be found
at www.it-modernisation.com.
Or just send us an E-Mail:
[email protected].
© 2008-2015 Schierholz IT Modernisation GmbH
Assembler to COBOL
28