Converting Programs from PLX to assembler Lighthearted view
Converting Programs from PL/X to assembler. • Lighthearted view on PL/X programming language. • Not intended as a criticism of PL/X. • Business and technical decision to move away from PL/X. • Surprise! It’s no longer available from IBM. That settles it. MVMUA VM RESOURCES LTD.
What is PL/X? • IBM programming language. • High level language. • Generates source assembler as input to assembler module. • Follow on to PL/S. • Look enough like PL/I to raise false hopes. MVMUA VM RESOURCES LTD.
My PL/S Experience • First task as a system programmer in IBM Canada was support the “HONE” system. • Turnover was a handshake and pat on the back. • It broke! • Had to debug with no knowledge but at least some assembler! • My favorite: GENERATE prodcues Assembler code inside PL/S. MVMUA VM RESOURCES LTD.
Converting • Started with smallest PLX routines. • Took the assembler output and worked it in Xedit update mode. • Changed PL/X macros to assembler macros. • Deleted nasty equates. • Removed unused and unreferenced symbols and equates. • Changed logic when required. • Worth the effort? Yup! MVMUA VM RESOURCES LTD.
Why I Fear PL/X -- Why PL/X Bogs Down Work at VMR • Documentation is hard to get. • Debugging tools are poor. • Not worth the investment to learn myself, or properly train staff. • Patch it all in assembler anyway. MVMUA VM RESOURCES LTD.
Why I Fear PL/X -- Why PL/X Bogs Down Work at VMR • Lack of documentation requires long psychoanalysis to puzzle out what code is doing and stretches out learning time. • A few lines of PL/X generates great gobs of code with severely weird naming. MVMUA VM RESOURCES LTD.
Patch it all in assembler anyway • Compile the PL/X. • Take the assembler output and use the CMS source update facility. • Better not change the PL/X source or you’re in for a retrofitting nightmare. MVMUA VM RESOURCES LTD.
PL/X Issues • • • Long winded and verbose. Lots of EQUATE symbols. Nasty symbol naming. Limited set of functions. Poor string handling. MVMUA VM RESOURCES LTD.
Verbose: PL/X Extract if (rc ¬= ss_srv_rc_success) then do; ? DMSMSG TEXT('rc: &1, reason: &2') SUB(DEC, rc, DEC, re); Return Code (-1); end; Declare p rc re pointer(31), fixed(31); . . . ss_srv_rc_success MVMUA fixed(31) constant(0), VM RESOURCES LTD.
Long winded expansions! This logic checks a return code and puts out a message if return code not equal to 0: 69 70 71 72 73 74 75 76 77 78 *if (rc ¬= ss_srv_rc_success) then ICM @04_RC, 15, RC BZ @RF 00033 *do; * /* DMSMSG TEXT('rc: &1, reason: &2')SUB(DEC, rc, DEC, re)* * BEGIN; * * DCL 1 $MSG_PLIST BIT(248)BOUNDARY(BYTE), * 2 $MODULE_NAME CHAR(8), * 2 $FLAGS BIT(16), 79 * 80 * 81 * 82 * 83 * 84 * 85 * MVMUA : 2 $DISPOSITION BIT(8), 2 $MESSAGE PTR(31) BOUNDARY(BYTE), /* NUM/FMT/LINE OR 3 $NUMBER BIN(16) BOUNDARY(BYTE), 3 $FORMAT BIN(8), 3 $LINE BIN(8), 2 $SEVERITY_LETTER CHAR(1), VM RESOURCES LTD.
Very Long Winded!. . 86 87 88 89 90 91 92 93 94 95 96 97 98 98 99 00 01 02 03 04 05 06 07 08 09 MVMUA * * * * * 2 $CSECT CHAR(3), 2 $SUBSTITUTION(2) BIT(48), /* MSG SUBSTITUTION 3 $FLAG BIT(8), 3 $VALUE BIN(31) BOUNDARY(BYTE), 4 $VALUEAD PTR(31) BOUNDARY(BYTE), 3 $LENG FIXED(8), 2 * CHAR(0); $MSG_PLIST = 'C 4 D 4 E 2 D 4 C 7 D 4404068000100005 C 6 F 6 F 6 F XC @GN 00382+19(12), @GN 00382+19 MVC @GN 00382(19), @CB 00100 DCL 1 $TEXT, /* DECLARE VARIABLE 2 $TEXT_LENGTH BIN(8), 2 $TEXT_STRING CHAR(LENGTH( 'rc: &1, reason: &2' $TEXT_LENGTH = LENGTH( 'rc: &1, reason: &2')+1; MVI @GN 00410, X'13' $TEXT_STRING = 'rc: &1, reason: &2'; MVC @GN 00411(19), @CC 00103 $MSG_PLIST. $MESSAGE = ADDR($TEXT); LA @05, @GN 00409 STCM @05, 15, @GN 00389 $MSG_PLIST. $SUBSTITUTION. $FLAG(1) = '01'X; MVI @GN 00401, X'01' VM RESOURCES LTD. 11
All this to get out a message!. . 10 * 11 12 * 13 14 * $MSG_PLIST. $SUBSTITUTION. $VALUE(1) = FIXED( rc); STCM @04_RC, 15, @GN 00402 $MSG_PLIST. $SUBSTITUTION. $FLAG(2) = '81'X; MVI @GN 00401+6, X'81' $MSG_PLIST. $SUBSTITUTION. $VALUE(2) = FIXED(re); 14 * $MSG_PLIST. $SUBSTITUTION. $VALUE(2) = FIXED(re); 15 MVC @GN 00402+6(4), RE 16 * DCL GPR 0001 REG(1) RESTRICTED; 17 * DCL GPR 000 F REG(15) RESTRICTED; 18 * GPR 0001 = ADDR($MSG_PLIST); /* SET R 1 TO POINT 19 LA @GN 00412, @GN 00382 20 * GEN CODE; 21 @GS 00049 DS 0 H 22 CMSCALLTYP=PROGRAM, ERROR =*, COPY=NO 23+ DS 0 H 24+ SR 15, 15 25+ O 15, =X'0000' 26+ SVC 204 27 @GE 00049 DS 0 H 28 * RESPECIFY GPR 0001 UNRESTRICTED; 29 * RESPECIFY GPR 000 F UNRESTRICTED; 30 * END; MVMUA VM RESOURCES LTD. 12
In assembler the same logic 100 *+ 101 ICM R 5, 15, RE 102 LA R 6, L'DBUFD+L'DBUF 103 STC R 6, DBUF 104 LA R 6, DBUF 105 MVI DBUFD, X'40' 106 MVC DBUFD+1(L'DBUFD-1), DBUFD 107 MVC DBUFD, =C'RC: &&1 Reason Code: &&2 ' 108 LA R 10, D_APPLMSG 109 APPLMSG APPLID=VMR, TEXTA=(R 6), SUB=(DEC, (R 4), DEC, (R 5)), MF=(E, (R 10)) 110+ CNOP 0, 4 111+ B DMSB 0003 BRANCH AROUND PLIST 112+DMSA 0003 DS 0 H 113+ DC CL 8'DMSMGM' 114+ DC AL 1(120, 0, 1) FLAG BYTES 115+ DC AL 4(0) 116+ DC CL 1'*' SET UP LET IN PLIST 117+ DC CL 3'RSK' SET UP CSECT IN PLIST : MVMUA VM RESOURCES LTD.
A few more lines : 118+ 119+ 120+ 121+ 122+ 123+ 124+ 125+DMSB 0003 126+ 127+ 128+NT 3 C 0003 129+CONT 0003 130+ 131+ 132+ 133+ 134+ : MVMUA DC DC DS LR MVC DS DS STCM DS SR O SVC CL 3'VMR' AL 1(9) SET OPTION AL 4(R 4) WAS A REG, X'00' AL 1(137) SET OPTION AL 4(R 5) WAS A REG, X'00' 0 H 1, (R 10) 0(DMSB 0003 -DMSA 0003, 1), DMSA 0003 0 H 0 H R 6, B'1111', 11(1) 0 H 15, 15 15, =X'0000 A 000' 204 VM RESOURCES LTD. CODE CONSTANT O
The data areas From a dsect: . 242 DBUF DC XL 1'00' 243 DBUFD DC CL 80'RC: &&1 Reason Code: &&2 ' 244 ORG DBUFD 245 DC CL 80'Linux/VM Has Shutdown' 246 D_APPLMSG MF=L, MAXSUBS=4 247+D_APPLMSG DS 50 X 248+ DS 0 H MVMUA VM RESOURCES LTD.
The Results 16: 47: 50 16: 47: 50 found 16: 47: 50 vmrhttp IBM VM/ESA Reusable Server Kernel (C) Copyright 1993, 1994, 1995, 1996, 1997, 1998 International Business Machines Corporation. All Rights Reserved. DMSEXE 085 E Error in PROFILE RSK *, line 0 - file not Linux/VM has Shutdown 16: 47: 50 rc: 8, reason: 10001 MVMUA VM RESOURCES LTD.
Oh those EQUATE symbols! • Look at these nasty equates and all the squiggly characters!: 374 EXIT_SUBFN_1 EQU 0, 24, C'C' 375 @GN 00165 EQU EXIT_SUBFN_1, 2, C'H' 376 @GN 00166 EQU EXIT_SUBFN_1+2, 2, C'H' 377 @GN 00167 EQU EXIT_SUBFN_1+4, 4, C'A' 378 @GN 00168 EQU EXIT_SUBFN_1+8, 1, C'C' 379 @GN 00169 EQU EXIT_SUBFN_1+9, 1, C'C' 380 @GN 00170 EQU EXIT_SUBFN_1+10, 2, C'H' 384 @GN 00176 EQU EXIT_SUBFN_5, 2, C'H' 385 @GN 00177 EQU EXIT_SUBFN_5+2, 2, C'H' 386 @GN 00178 EQU EXIT_SUBFN_5+4, 4, C'A' 387 @GN 00179 EQU EXIT_SUBFN_5+8, 1, C'C' 388 @GN 00180 EQU EXIT_SUBFN_5+9, 1, C'C' 389 @GN 00181 EQU EXIT_SUBFN_5+10, 2, C'H' 390 RXSSIZE EQU EXIT_SUBFN_5+16, 4, C'F' MVMUA VM RESOURCES LTD.
Compiler Choices (not mine) • Why? • AL ST @03_@OV 00030, RESPONSE_LEN @03_@OV 00030, DS_OFF(@02_@OV 00025) : @02_@OV 00025 EQU @02 @03_@OV 00030 EQU @03 • Why not just? MVMUA AL R 3, RESPONSE_LEN ST R 3, DS_OFF(R 2) VM RESOURCES LTD.
Conclusions • Will convert all programs away from PL/X. • Just too many hard to manage situations. • PL/X source is not that much smaller than well written Assembler. • With Assembler, we know exactly what we are doing and when we have to do deep debugging we can use all the CP and CMS debugging facilities. • I’d rather do it in assembler. MVMUA VM RESOURCES LTD.
- Slides: 19