|
|||||
|
This suite of programs provides an example of how a mainframe assembler program calls, loads or links to a mainframe assembler (HLASM) routine. The assembler programs are written in IBM Mainframe Assembler, they will compile using Assembler/H or HLASM. A JCL member is provided to run the job as an MVS batch job on an IBM mainframe or as a project with Micro Focus Mainframe Express (MFE) running on a PC with Windows.
This program may serve as a tutorial for programmers that are new to 370 Assembler and as a reference for experienced programmers.
Note: The source code for this example is available from the SimoTime Library under Download Directory at www.simotime.com
There are four JCL members included with this example. The first example demonstrates the use of the CALL macro. The second example demonstrates the use of the LOAD macro with additional code to branch and execute the loaded member. The third example demonstrates the use of the LINK macro to dynamically link to an assembler member. The fourth example is a single job with multiple job steps that demonstrates the CALL, LOAD and LINK macro usage.
The JOB statements in each of the following examples will need to be modified for specific mainframe environments.
The following is the mainframe JCL (ASMASMJ1.JCL) required to run the mainline program that demonstrates the use of the CALL macro. The JOB statement will need to be modified for specific mainframe environments. This will also run on the PC using Mainframe Express provided by Micro Focus.
//ASMASMJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=LRSP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - 370 Assembler, Assembler calling Assembler //* Author - SimoTime Enterprises //* Date - January 01, 1997 //* //* This 370 Assembler program is an example of the Call function //* of mainframe assembler. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* Step 1 This is a single step job. //* //ASMASMS1 EXEC PGM=ASMASMA1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //*
The following is the mainframe JCL (ASMASMJ2.JCL) required to run the mainline program that demonstrates the use of the LOAD macro. . The JOB statement will need to be modified for specific mainframe environments. This will also run on the PC using Mainframe Express provided by Micro Focus.
//ASMASMJ2 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=LRSP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - 370 Assembler, Assembler loading Assembler //* Author - SimoTime Enterprises //* Date - January 01, 1997 //* //* This 370 Assembler program an example of the Load function //* of mainframe assembler. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* Step 1 This is a single step job. //* //ASMASMS1 EXEC PGM=ASMASMA2 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //*
The following is the mainframe JCL (ASMASMJ3.JCL) required to run the mainline program that demonstrates the use of the LINK macro. The JOB statement will need to be modified for specific mainframe environments. This will also run on the PC using Mainframe Express provided by Micro Focus.
//ASMASMJ3 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=LRSP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - 370 Assembler, Assembler using a Dynamic Link //* Author - SimoTime Enterprises //* Date - January 01, 1997 //* //* This 370 Assembler program an example of the Link function //* of mainframe assembler. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* Step 1 This is a single step job. //* //ASMASMS1 EXEC PGM=ASMASMA3 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //*
The following is the mainframe JCL (ASMASMJA.JCL) required to run the mainline program that demonstrates the use of the CALL macro. The JOB statement will need to be modified for specific mainframe environments. This will also run on the PC using Mainframe Express provided by Micro Focus.
//ASMASMJA JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=LRSP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Text - 370 Assembler, Sample of CALL, LOAD, and LINK //* Author - SimoTime Enterprises //* Date - January 01, 1997 //* //* This 370 Assembler program an example of the Call, Load and Link //* functions of mainframe assembler. //* //* This set of programs will run on a mainframe under MVS or on a //* Personal Computer with Windows and Micro Focus Mainframe Express. //* //* ******************************************************************* //* Step 1 Demonstrate the use of the CALL macro. //* //ASMASMS1 EXEC PGM=ASMASMA1 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //* //* ******************************************************************* //* Step 2 Demonstrate the use of the LOAD macro. //* //ASMASMS2 EXEC PGM=ASMASMA2 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //* //* ******************************************************************* //* Step 3 Demonstrate the use of the LINK macro. //* //ASMASMS3 EXEC PGM=ASMASMA3 //STEPLIB DD DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR //*
These programs are provided as examples and were written to be used as teaching and learning aids.
This program (ASMASMA1.MLC) uses the CALL macro to pass parameters to another assembler member (ASMASMAA.MLC) for processing. The CALL macro will generate the code required to build a parameter list and pass control to the called member.
ASMASMA1 CSECT
***********************************************************************
* This program is provided by: *
* SimoTime Enterprises, LLC *
* (C) Copyright 1987-2003 All Rights Reserved *
* *
* Web Site URL: http://www.simotime.com *
* e-mail: helpdesk@simotime.com *
***********************************************************************
* *
* Created: 1993/06/01, Simmons *
* Changed: 1993/06/01, Simmons, no changes to date... *
* *
***********************************************************************
* *
* This program will run an an IBM Mainframe using MVS or a PC using *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with *
* the Assembler Option. *
* *
* This program provides an example of an assembler program using the *
* call macro to pass control to another assembler program. *
* *
* Using the Micro Focus Animation you can immediately see the results *
* of each instruction execution. This is a very effective way to *
* become familiar with how these techniques work. *
* *
***********************************************************************
* This program provides an example of the CALL macro. *
***********************************************************************
SAVE (14,12)
BALR 12,0 PREPARE A BASE REGISTER
USING *,12 ESTABLISH BASE REGISTER
ST R13,SAVREG13
*
WTO '* ASMASMA1 is starting, example of CALL macro...'
*
*---------------------------------------------------------------------*
* The following routine is an example of calling another program using
* the CALL macro. The following will not pass parameters. Since the
* CALLed program test for this condition a message will be displayed.
* Standard member-to-member linkage is used. The CALL macro will
* generate the code to pass control to the CALLed program. The CALLed
* program should return to the next line a code in this program.
*
WTO '* ASMASMA1 calling ASMASMAA without parameters...'
LA R13,SAVEAREA
SR R1,R1
CALL ASMASMAA
WTO '* ASMASMA1 return...'
*
*---------------------------------------------------------------------*
* The following routine is an example of calling another program using
* the CALL macro. The following will pass parameters. Parameters are
* passed via an address list.
* Standard member-to-member linkage is used.
* The CALL macro will generate the code to pass control to the CALLed
* program. The CALLed program should return to the next line a code
* in this program.
*
WTO '* ASMASMA1 calling ASMASMAA with four parameters...'
LA R13,SAVEAREA
CALL ASMASMAA,(PARM01,PARM02,PARM03,PARM04),VL
WTO '* ASMASMA1 return...'
*
*---------------------------------------------------------------------*
EOJAOK EQU *
WTO '* ASMASMA1 is complete, example of CALL macro......'
L R13,SAVREG13
RETURN (14,12),RC=0
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 8
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
ABEND08 EQU *
WTO '* ASMASMA1 is abending...RC=0008'
L R13,SAVREG13
RETURN (14,12),RC=8
*
***********************************************************************
* Define Constants and EQUates
*
DS 0F + Force alignment
*
SAVEAREA EQU *
DC F(0)
DC F(0)
SAVREG13 DC F(0)
DC 15F(0) * Used by SAVE/RETURN functions
*
PARM01 DC H(28),H(0),CL24'* ASMASMA1 parameter 01 '
PARM02 DC H(28),H(0),CL24'* ASMASMA1 parameter 02 '
PARM03 DC H(28),H(0),CL24'* ASMASMA1 parameter 03 '
PARM04 DC H(28),H(0),CL24'* ASMASMA1 parameter 04 '
*
* Register EQUates
*
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
*
END
This program (ASMASMA2.MLC) uses the LOAD macro to load another member into memory (ASMASMAA.MLC). The LOAD macro will only generate the code to load the member into memory, It will not generate the code to build a parameter list or pass control to the loaded member. It is the programmer's responsibility to build the parameter list and pass control to the loaded member. This example also shows the necessary code to build a parameter list and branch to the loaded member and pass parameters for processing.
Notice how the high-order bit of the address of the last parameter is set on to indicate it is the last parameter.
ASMASMA2 CSECT
***********************************************************************
* This program is provided by: *
* SimoTime Enterprises, LLC *
* (C) Copyright 1987-2003 All Rights Reserved *
* *
* Web Site URL: http://www.simotime.com *
* e-mail: helpdesk@simotime.com *
***********************************************************************
* *
* Created: 1993/06/01, Simmons *
* Changed: 1993/06/01, Simmons, no changes to date... *
* *
***********************************************************************
* *
* This program will run an an IBM Mainframe using MVS or a PC using *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with *
* the Assembler Option. *
* *
* This program provides an example of an assembler program using the *
* load macro to pass control to another assembler program. *
* *
* Using the Micro Focus Animation you can immediately see the results *
* of each instruction execution. This is a very effective way to *
* become familiar with how these techniques work. *
* *
***********************************************************************
* This program provides an example of the LOAD macro. *
***********************************************************************
SAVE (14,12)
BALR 12,0 PREPARE A BASE REGISTER
USING *,12 ESTABLISH BASE REGISTER
ST R13,SAVREG13
*
WTO '* ASMASMA2 is starting, example of LOAD macro......'
*
*---------------------------------------------------------------------*
* The following routine is an example of loading another program using
* the LOAD macro. The member will be loaded. The address of where the
* member is loaded is returned in register zero.
* The following show how to pass parameters. Parameters are passed via
* an address list. Standard member-to-member linkage is used.
* The BALR will branch to the address in register 15 and provide a
* linkage address back to the next line of code in this member via
* register 14.
*
WTO '* ASMASMA2 loading ASMASMAA with four parameters...'
LOAD EP=ASMASMAA
LTR R15,R15
BNZ LOADFAIL
* Member is now loaded, the following will branch-and-link to the
* loaded member.
LA R13,SAVEAREA
LA R1,ADDRLIST * Load reg-1 with paramater list
LR R15,R0 * Load reg-15 with addr of load member
BALR R14,R15 * Branch to Load member, return via R14
WTO '* ASMASMA2 return...'
*
*---------------------------------------------------------------------*
EOJAOK EQU *
WTO '* ASMASMA2 is complete, example of LOAD macro......'
L R13,SAVREG13
RETURN (14,12),RC=0
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 4 *
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM *
*
LOADFAIL EQU *
WTO '* ASMASMA2 is abending...Load Failure...RC=0004'
L R13,SAVREG13
RETURN (14,12),RC=8
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 8 *
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM *
*
ABEND08 EQU *
WTO '* ASMASMA2 is abending...RC=0008'
L R13,SAVREG13
RETURN (14,12),RC=8
*
***********************************************************************
* Define Constants and EQUates *
*
DS 0F + Force alignment
*
SAVEAREA EQU *
DC F(0)
DC F(0)
SAVREG13 DC F(0)
DC 15F(0) * Used by SAVE/RETURN functions
*
PARM01 DC H(28),H(0),CL24'* ASMASMA2 parameter 01 '
PARM02 DC H(28),H(0),CL24'* ASMASMA2 parameter 02 '
PARM03 DC H(28),H(0),CL24'* ASMASMA2 parameter 03 '
PARM04 DC H(28),H(0),CL24'* ASMASMA2 parameter 04 '
*
***********************************************************************
* When an assembler program is called register 1 normally contains *
* the address of an address list. The addresses in the address list *
* could be 24 or 31 bit addresses with the high order bit set to 0 *
* for all addresses except the last address that has the high-order *
* bit set to 1. *
*
ADDRLIST EQU * * Build an address list
DS 0H
DC AL4(PARM01)
DC AL4(PARM02)
DC AL4(PARM03)
DC AL4(PARM04+262144*8192)
*
* Register EQUates
*
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
*
END
This program (ASMASMA3.MLC) uses the LINK macro to dynamically load and link to another member (ASMASMAA.MLC). The expanded code will be generated by the LINK macro to load the member into memory, build a parameter list and then link to the member for processing.
ASMASMA3 CSECT
***********************************************************************
* This program is provided by: *
* SimoTime Enterprises, LLC *
* (C) Copyright 1987-2003 All Rights Reserved *
* *
* Web Site URL: http://www.simotime.com *
* e-mail: helpdesk@simotime.com *
***********************************************************************
* *
* Created: 1993/06/01, Simmons *
* Changed: 1993/06/01, Simmons, no changes to date... *
* *
***********************************************************************
* *
* This program will run an an IBM Mainframe using MVS or a PC using *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with *
* the Assembler Option. *
* *
* This program provides an example of an assembler program using the *
* link macro to pass control to another assembler program. *
* *
* Using the Micro Focus Animation you can immediately see the results *
* of each instruction execution. This is a very effective way to *
* become familiar with how these techniques work. *
* *
***********************************************************************
* This program provides an example of the LINK macro. *
***********************************************************************
SAVE (14,12)
BALR 12,0 PREPARE A BASE REGISTER
USING *,12 ESTABLISH BASE REGISTER
ST R13,SAVREG13
*
WTO '* ASMASMA3 is starting, example of LINK macro......'
*
*---------------------------------------------------------------------*
* The following routine is an example of dynamically linking to
* another program using the LINK macro.
* The following will pass parameters. Parameters are passed via an
* address list. Standard member-to-member linkage is used.
* The LINK macro will generate the code to pass control to the target
* program. The taret program should return to the next line a code
* in this program.
*
WTO '* ASMASMA3 linking to ASMASMAA with four parameters...'
LA R13,SAVEAREA
LINK EP=ASMASMAA,PARAM=(PARM01,PARM02,PARM03,PARM04),VL=1
WTO '* ASMASMA3 return...'
*
*---------------------------------------------------------------------*
EOJAOK EQU *
WTO '* ASMASMA3 is complete, example of LINK macro......'
L R13,SAVREG13
RETURN (14,12),RC=0
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 8
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
ABEND08 EQU *
WTO '* ASMASMA3 is abending...RC=0008'
L R13,SAVREG13
RETURN (14,12),RC=8
*
***********************************************************************
* Define Constants and EQUates
*
*
DS 0F + Force alignment
*
SAVEAREA EQU *
DC F(0)
DC F(0)
SAVREG13 DC F(0)
DC 15F(0) * Used by SAVE/RETURN functions
*
PARM01 DC H(28),H(0),CL26'* ASMASMA3 parameter 01 '
PARM02 DC H(28),H(0),CL26'* ASMASMA3 parameter 02 '
PARM03 DC H(28),H(0),CL26'* ASMASMA3 parameter 03 '
PARM04 DC H(28),H(0),CL26'* ASMASMA3 parameter 04 '
*
* Register EQUates
*
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
*
END
This program (ASMASMAA.MLC) is the routine that is called to validate and display the parameters passed from the calling ptograms. The program provides a minimum of visual information when it is executed on the mainframe. The real value to this program is when it is animated using the 370 Assembler Option of Mainframe Express provided by Micro Focus. It is possible to watch the actual execution of each individual instruction and to immediately see the results.
ASMASMAA CSECT
***********************************************************************
* This program is provided by: *
* SimoTime Enterprises, LLC *
* (C) Copyright 1987-2003 All Rights Reserved *
* *
* Web Site URL: http://www.simotime.com *
* e-mail: helpdesk@simotime.com *
***********************************************************************
* *
* Created: 1993/06/01, Simmons *
* Changed: 1993/06/01, Simmons, no changes to date... *
* *
***********************************************************************
* *
* This program will run an an IBM Mainframe using MVS or a PC using *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with *
* the Assembler Option. *
* *
* This program provides an example of an assembler program that *
* receives control from another program via a call, load or link. *
* *
* Using the Micro Focus Animation you can immediately see the results *
* of each instruction execution. This is a very effective way to *
* become familiar with how these techniques work. *
* *
***********************************************************************
SAVE (14,12)
BALR 12,0 PREPARE A BASE REGISTER
USING *,12 ESTABLISH BASE REGISTER
*
LTR R1,R1
BZ NOPARMS
*
LR R2,R1 * Put addr of addr list into reg-2
*
WTO '* ASMASMAA is starting...'
*
LA R3,TOOMANY * Limit loop count to reg-3 value
LA R4,4 * Set reg-4 to four (Loop Limit)
*
ADDRLOOP EQU *
L R5,0(,R2) * Use reg-5 for WTO address
WTO MF=(E,(R5))
TM 0(,R2),X'80' * Is this last parameter...
BO EOJAOK * If yes, Branch out of loop...
LA R2,4(,R2) increment to next addr in list
BCT R4,ADDRLOOP Else, decrement parameter count
B TOOMANY * Too-many or invalid parm list
*
*---------------------------------------------------------------------*
* NORMAL END-OF-JOB
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
EOJAOK EQU *
WTO '* ASMASMAA is returning...'
RETURN (14,12),RC=0
*
***********************************************************************
* ABENDING WITH RETURN-CODE OF 8
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
ABEND08 EQU *
WTO '* ASMASMAA is abending...RC=0008'
RETURN (14,12),RC=8
*
***********************************************************************
* Post a non-paramter message...
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
NOPARMS EQU *
WTO '* ASMASMAA called with zero parameters'
RETURN (14,12),RC=4
*
***********************************************************************
* Post a too-many-paramters message...
* RETURN to the CALLING PROGRAM OR OPERATING SYSTEM
*
TOOMANY EQU *
WTO '* ASMASMAA called with too many parameters'
RETURN (14,12),RC=4
*
***********************************************************************
* Define Constants and EQUates
*
DS 0F + Force alignment
*
* Register EQUates
*
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
*
END
The purpose of this document is to assist as a tutorial for new assembler programmers or as a quick reference for experienced programmers. The samples focus on the coding techniques of the individual instructions. As always, it is the programmer's responsibility to thoroughly test all programs.
Permission to use, copy, modify and distribute this software for any non-commercial purpose and without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for any commercial purpose requires a fee to be paid to Simotime Enterprises. Once the fee is received by SimoTime the latest version of the software will be delivered and a license will be granted for use within an enterprise, provided the SimoTime copyright notice appear on all copies of the software. The SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software for any purpose. It is provided "AS IS" without any express or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential damages resulting from the loss of use, data or projects, whether in an action of contract or tort, arising out of or in connection with the use or performance of this software.
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
Check out The Assembler Connection for more examples of mainframe Assembler coding techniques and sample code.
Check out The SimoTime Library for a wide range of topics for Programmers, Project Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com
Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com
| Return-to-Top |
| Copyright © 1987-2008 SimoTime Enterprises, LLC All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |