Assembler to COBOL The fully automated transformation using TRAVERT ®.A2C Explained along the...
-
Upload
shannon-neale -
Category
Documents
-
view
221 -
download
2
Transcript of Assembler to COBOL The fully automated transformation using TRAVERT ®.A2C Explained along the...
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
Contents
IntroductionSimple patterns
Handling commentsStorage definitionsRelative jumpsTransformation of code-molecules.Here: B/NOP, UNPK/OI, Field Padding with MVI/MVC, EX, ED/EDMK
Complex and highly complex patternsResolving the OS Linkage ConventionFiles: definition and accessDetection and transformation of subroutinesTables: definition and access
Introduction Simple Patterns Complex Patterns Synopsis
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL 2
The companyIntroduction Simple Patterns Complex Patterns Synopsis The company Products The demo program
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
Schierholz IT Modernisation GmbH is the expert in
Areas of applicationAnalysis 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 servicesSignificant 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.
automated processing of computer languages
3
ProductsIntroduction Simple Patterns Complex Patterns Synopsis The company Products The demo program
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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#
4
This Presentation ...Introduction Simple Patterns Complex Patterns Synopsis The company Products The demo program
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
... 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:
The resulting COBOL program works identically and error-free without any manual post processing!
Everything is done fully automated!
Before you are going into the details we recommend that you download the accompanying material
and have it ready as a reference.
5
The Demo Program A2CP2Introduction Simple Patterns Complex Patterns Synopsis The company Products The demo program
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
Input:ZIP code,
requestor ID, priority
Output:Listing
AUTHTABID, authority
name
CITYTABZIP, city name,
inhabitants
A2CP2checks and
completes the read-in records
uses twointernal tables
6
Simple PatternsIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
Handling comments
Storage definition
Relative jumps
Transformation of so-called code molecules
7
Relocating the Program DescriptionIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
*********************************************************************** 1.1* 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.2
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***********************************************************************
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.
8
Inserting the Transformation HistoryIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
*----------------------------------------------------------------* * 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 *----------------------------------------------------------------*
A2C generates informationregarding the program
and the transformation process directly behind the program description.
9
Heading BlocksIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
*********************************************************************** 8.2* Print final statistics***********************************************************************PRTS14 DC F'-1'PRTSTATS DS 0H
*********************************************************************** * Print final statistics *********************************************************************** PRTSTATS SECTION. PRTSTATS-Start.
Pattern matching has identified PRTSTATSand other sequences as subroutines.
Now the comment block directly preceding »PRTS14« can be moved
to the start of the COBOL representation of the subroutine.
10
Dealing With Inline CommentsIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
A2C offers 3 different options to deal with inline comments1. TRANSFORM – transforms inline comments into COBOL full-line comments, which can be placed either
before or after the related line
2. REMOVE – deletes inline comments
3. 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.
11
A Relative JumpIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
CP LINECNT,=P'50' max 50 lines here BL *+14 no header to be printed 5.1AP PAGECNT,=P'1' BAL R14,PRTHDR print header line(s) 6.1MVI INERR,X'00' reset indicator 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.
12
Location Counter and Storage AddressesIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
INREC DS 0CL80INZIP DS CL5 DS CINREQID DS CL4 requesting authority DS CINPRI DS C ORG INREC+L'INREC 3
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).
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«.
The length attribute »0« in »0CL80«is transformed into a »FILLER REDEFINES«.
13
Code-MoleculesIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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 replacedoften by a single COBOL instruction
or an elegant COBOL construct
Frequently encountered molecules areSelf-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.
14
Example B/NOPIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
MAIN NOP PASS01 4.1 MVI MAIN+1,X'F0' next time no file OPEN 4.2
MAIN. IF SW-1-JUMP GO TO PASS01 END-IF SET SW-1-JUMP TO TRUE
A2C replaces this molecule by a switch, which is queried instead of the »NOP«.
77 SW-1 PIC X VALUE 'N'. 88 SW-1-JUMP VALUE 'Y'. 88 SW-1-NO-JUMP VALUE 'N'.
The definition of the switch is generated automatically into the WORKING STORAGE SECTION.
15
Molecules UNPK/OI and Field PaddingIntroduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
02 HDR1PG-0ZL3 PIC 999.
A2C generates a „character numeric“ redefinition of »HDR1PG«.
MOVE PAGECNT TO HDR1PG-0ZL3
Thereafter the molecule can be replaced by a single »MOVE«.
MOVE ALL '?' TO DETAUTH
The so-called field padding is substituted by a simple »MOVE ALL«.
UNPK HDR1PG,PAGECNT 9.1OI HDR1PG+L'HDR1PG-1,X'F0' 9.2
UNPK/OI
MVI DETAUTH,C'?' 17.1MVC DETAUTH+1(L'DETAUTH-1),DETAUTH 17.2
Field Padding
16
Molecule „EX“Introduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
PACK DWD,INPRI 10.4CVB R2,DWD BCTR R2,0 10.5EX R2,MVCSTAR 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.
MOVE INPRI-0ZL1 TO DWD-0PL8 MOVE DWD-0PL8 TO Demo-R2Lo-S SUBTRACT 1 FROM Demo-R2Lo MOVE STARS TO DETPRI(1:(Demo-R2Lo + 1))
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”.
MVCSTAR MVC DETPRI(0),STARS 10.2
17
Molecule „ED/EDMK“Introduction Simple Patterns Complex Patterns Synopsis Comments Addressing Rel. Jumps Code-Molecules
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
MVC DETINH,=X'402020206B2120206B202020' 11.2ED DETINH,DWD+3 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.
MOVE DWD-3PL5 TO DETINH.
Having achieved this, a simple »MOVE« is all we need to resolve the ED instruction.
02 DETINH PIC BZZZ,Z99,999.
18
Complex PatternsIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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
19
Transforming the OS Linkage ConventionIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
SAVE (14,12) 2.1 LR R12,R15 get base address USING A2CP2,R12 LA R2,SAVEAREA ST R2,8(R13) link to next SA ST R13,4(R2) link to prev SA LR R13,R2 2.2
LA R15,0 2.3 L R13,4(R13) Caller's SA RETURN (14,12),RC=(15) 2.4
MOVE 0 TO RETURN−CODE GOBACK.
This is only one of numerous patterns and variants of the program initialization.
The code is recognized and removed completely!
This is a typical pattern for setting the return codeand returning to the caller.
This leads to the following COBOL code:
20
File Input and OutputIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
The sample assembler program contains an input and an output file.
As a consequence (among others) the following statements must be transformed:
NB.: The demo program was written for z/OS. Of course A2C supports also the macros of z/VSE and BS2000.
INFILE DCB BLKSIZE=80,LRECL=80,MACRF=GM,EODAD=INEND,DDNAME=INFILE, +14.5 DSORG=PS INEND DS 0H end of input file reached 14.3OUTLST 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
21
Files in COBOLIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to 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
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.
22
SubroutinesIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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.
23
Detecting and Transforming SubroutinesIntroduction Simple Patterns Complex Patterns Synopsis Rel. Jumps Subroutines Tables Files
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
BAL R14,PRTHDR print header line(s) 6.1
DS F PRTHDR DS 0H ST R14,*-4 save R14 6.3 . . . L R14,PRTHDR-4 6.4 BR R14 6.5
The »BAL«-instruction becomes a COBOL »PERFORM«. The total routine is moved into the so-called „A2C Subroutine Pool”.
In the end we need only3 COBOL statements as a replacement.
PERFORM PRTHDR.
PRTHDR SECTION.PRTHDR-Start.
Customers tend to have their own methods to call subroutines. It is very easy to teach A2C any new kind of pattern.
24
Tables – One of The Most Complex SubjectsIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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 byDefinition 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 recognizedHead-, 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.
25
TablesIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
GET010 DS 0H LA R3,AUTHTAB GETLOOP DS 0H CLI 0(R3),X'FF' BE GETNOTFD not found CLC INREQID,0(R3) BE GETFD match! LA R3,24(R3) B GETLOOP GETFD DS 0H MVC DETAUTH,4(R3) B GETEND GETNOTFD DS 0H MVI DETAUTH,C'?' MVC DETAUTH+1(L'DETAUTH-1),DETAUTH MVC DETAUTH(L'INREQID),INREQID AP ERRCNT,=P'1' MVI INERR,X'FF' GETEND BR R14
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.
The access to »AUTHTAB« on the left can be found starting on line 176 in the assembler source code.
How A2C converts this logic fully automated into COBOL is shown on the next slide.
26
TablesIntroduction Simple Patterns Complex Patterns Synopsis Linkage Files Subroutines Tables
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
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 SET AuthTbl-Index UP BY 1 GO TO GETLOOP. GETFD. 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.
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.
A2C transforms the assembler table access (see preceding slide) fully automated
into the COBOL sequence on the left.
27
SynopsisIntroduction Simple Patterns Complex Patterns Synopsis
© 2008-2015 Schierholz IT Modernisation GmbH Assembler to COBOL
The product TRAVERT®.A2C is capable of transforming mainframe-assembler-programs 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].
28