Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembler to COBOL The fully automated transformation using TRAVERT ®.A2C Explained along the example of a complete, executable assembler program © 2008.

Similar presentations


Presentation on theme: "Assembler to COBOL The fully automated transformation using TRAVERT ®.A2C Explained along the example of a complete, executable assembler program © 2008."— Presentation transcript:

1 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

2 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 Introduction Simple Patterns Complex Patterns Synopsis © Schierholz IT Modernisation GmbHAssembler to COBOL 2

3 The company Introduction Simple Patterns Complex Patterns SynopsisThe company Products The demo program © Schierholz IT Modernisation GmbHAssembler to COBOL Schierholz IT Modernisation GmbH is the expert in 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. automated processing of computer languages 3

4 Products Introduction Simple Patterns Complex Patterns SynopsisThe company Products The demo program © Schierholz IT Modernisation GmbHAssembler 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

5 This Presentation... Introduction Simple Patterns Complex Patterns SynopsisThe company Products The demo program © Schierholz IT Modernisation GmbHAssembler 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

6 The Demo Program A2CP2 Introduction Simple Patterns Complex Patterns SynopsisThe company Products The demo program © Schierholz IT Modernisation GmbHAssembler to COBOL Input: ZIP code, requestor ID, priority Output: Listing AUTHTAB ID, authority name CITYTAB ZIP, city name, inhabitants A2CP2 checks and completes the read-in records uses two internal tables 6

7 Simple Patterns Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL Handling comments Storage definition Relative jumps Transformation of so-called code molecules 7

8 Relocating the Program Description Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler 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

9 Inserting the Transformation History Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL * * * Entity A2CP2 * Transformed by Schierholz IT Modernisation GmbH * Baumwall 5, Hamburg, Germany * On :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 information regarding the program and the transformation process directly behind the program description. 9

10 Heading Blocks Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler 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 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. 10

11 Dealing With Inline Comments Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL A2C offers 3 different options to deal with inline comments 1.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

12 A Relative Jump Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL CP LINECNT,=P'50' max 50 lines here BL *+14 no header to be printed 5.1 AP PAGECNT,=P'1' BAL R14,PRTHDR print header line(s) 6.1 MVI 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

13 Location Counter and Storage Addresses Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL INREC DS 0CL80 INZIP DS CL5 DS C INREQID DS CL4 requesting authority DS C INPRI 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

14 Code-Molecules Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler 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 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. 14

15 Example B/NOP Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL MAIN NOP PASS 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

16 Molecules UNPK/OI and Field Padding Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler 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.1 OI HDR1PG+L'HDR1PG-1,X'F0' 9.2 UNPK/OI MVI DETAUTH,C'?' 17.1 MVC DETAUTH+1(L'DETAUTH-1),DETAUTH 17.2 Field Padding 16

17 Molecule „EX“ Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL PACK DWD,INPRI 10.4 CVB R2,DWD BCTR R2, EX 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

18 Molecule „ED/EDMK“ Introduction Simple Patterns Complex Patterns SynopsisComments Addressing Rel. Jumps Code-Molecules © Schierholz IT Modernisation GmbHAssembler to COBOL MVC DETINH,=X' B B202020' 11.2 ED DETINH,DWD 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,

19 Complex Patterns Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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

20 Transforming the OS Linkage Convention Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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 code and returning to the caller. This leads to the following COBOL code: 20

21 File Input and Output Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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, DSORG=PS INEND DS 0H end of input file reached 14.3 OUTLST DCB BLKSIZE=133,LRECL=133,MACRF=PM,RECFM=A,DDNAME=OUTLST, 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)

22 Files in COBOL Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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) 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

23 Subroutines Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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

24 Detecting and Transforming Subroutines Introduction Simple Patterns Complex Patterns SynopsisRel. Jumps Subroutines Tables Files © Schierholz IT Modernisation GmbHAssembler to COBOL BAL R14,PRTHDR print header line(s) 6.1 DS F PRTHDR DS 0H ST R14,*-4 save R L R14,PRTHDR BR R The »BAL«-instruction becomes a COBOL »PERFORM«. The total routine is moved into the so-called „A2C Subroutine Pool”. In the end we need only 3 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

25 Tables – One of The Most Complex Subjects Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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 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. 25

26 Tables Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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

27 Tables Introduction Simple Patterns Complex Patterns SynopsisLinkage Files Subroutines Tables © Schierholz IT Modernisation GmbHAssembler 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

28 Synopsis Introduction Simple Patterns Complex Patterns Synopsis © Schierholz IT Modernisation GmbHAssembler 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 Further information on our products and services can be found at Or just send us an 28


Download ppt "Assembler to COBOL The fully automated transformation using TRAVERT ®.A2C Explained along the example of a complete, executable assembler program © 2008."

Similar presentations


Ads by Google