Labels and Macro Files
Mainframe Assembler Coding Examples
  Table of Contents  v-16.01.01 - simolab1.htm 
  Introduction
  Sample Programs
  JCL for Sample Program
  Source Code for Mainline Program
  Macro with Branch & Labels
  Branch with a Specified Label
  Branch with a Generated Label
  Branch without a Label
  Provides for Alignment Considerations
  Summary
  Software Agreement and Disclaimer
  Downloads and Links
  Current Server or Internet Access
  Internet Access Required
  Glossary of Terms
  Comments or Feedback
  Company Overview
The SimoTime Home Page 

Table of Contents Previous Section Next Section Introduction

The creation and usage of labels within a mainframe assembler program is usually an easy task. One of the challenges in larger programs is to create unique labels. This was a problem with the early assembler compilers that had a limit of eight character names. With today's assembler compiler this has been increased to 64 characters.

The task of maintaining unique labels presented a bigger problem when using macros that generated code that included branch instructions. There are various techniques used to solve this problem and each has its own advantages and disadvantages.


We have made a significant effort to ensure the documents and software technologies are correct and accurate. We reserve the right to make changes without notice at any time. The function delivered in this version is based upon the enhancement requests from a specific group of users. The intent is to provide changes as the need arises and in a timeframe that is dependent upon the availability of resources.

Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved

Table of Contents Previous Section Next Section Sample Programs

This sample program is written entirely in mainframe assembler and will run as an MVS batch job on an IBM Mainframe System or as a project with Micro Focus Mainframe Express (MFE) running on a Windows System (refer to http://www.microfocus.com).  

     
SIMLABJ1
JCL
   
SIMLABA1
CSECT
Mainline Program
   
SIMLABM1
MACRO
Expanded macro code using a predefined label.
   
SIMLABM2
MACRO
Expanded macro code using a generated label.
   
SIMLABM3
MACRO
Expanded macro code using no labels.
   
SIMLABM4
MACRO
Expanded macro code with alignment considerations.
   
END
 
Program Structure with Links to Individual Functions

Table of Contents Previous Section Next Section JCL for Sample Program

The following is the mainframe JCL (SIMLABJ1.jcl) required to run the mainline program. This will run on an IBM Mainframe System with MVS or on a Windows System using Micro Focus Mainframe Express.

//SIMLABJ1 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=LRSP1
//* *******************************************************************
//*       This JCL Member is provided by SimoTime Technologies        *
//*           (C) Copyright 1987-2019 All Rights Reserved             *
//*             Web Site URL:   http://www.simotime.com               *
//*                   e-mail:   helpdesk@simotime.com                 *
//* *******************************************************************
//*
//* Text   -  370 Assembler, Sample use of labels
//* Author -  SimoTime Technologies
//* Date   -  January 01, 1997
//*
//* This 370 Assembler program provides different techniques for
//* generating unique labels or avoiding the use of labels within
//* expanded macro code.
//*
//* 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 of 1  This is a single step job.
//*
//SIMLABS1 EXEC PGM=SIMLABA1
//STEPLIB  DD  DSN=SIMOTIME.DEMO.LOADLIB1,DISP=SHR
//*

Table of Contents Previous Section Next Section Source Code for Mainline Program

The following is the mainframe assembler source code (SIMLABA1.mlc) for the mainline program that incorporates the use of the macro files to demonstrate the various ways to create label names or avoid creating label names within a macro.

SIMLABA1 CSECT
***********************************************************************
*             SIMLABA1.MLC - This is an HLASM Program                 *
*                 Provided by SimoTime Technologies                   *
*           (C) Copyright 1987-2019 All Rights Reserved               *
*             Web Site URL:   http://www.simotime.com                 *
*                   e-mail:   helpdesk@simotime.com                   *
***********************************************************************
*                                                                     *
* This program illustrates techniques used in macro coding to         *
* avoid creating labels or attempt to generate unique labels for      *
* macro generated code.                                               *
*                                                                     *
* This program will run on an IBM Mainframe using MVS or a PC using   *
* Micro Focus Mainframe Express, version 2.5 or later (MFE) with      *
* the Assembler Option.                                               *
*                                                                     *
* Created: 1992/06/01, Simmons                                        *
* Changed: 1992/06/01, Simmons, no changes to date...                 *
*                                                                     *
***********************************************************************
*
         BALR  12,0
         USING *,12
***********************************************************************
* Macro generated code that uses specific labels.                     *
*                                                                     *
* The advantage to this approach is that it is simple and easy        *
* to understand.                                                      *
*                                                                     *
* The disadvantage of this approach is that it may only be used       *
* once in a program. A second use of this macro in the same program   *
* will cause a duplicate label error.                                 *
***********************************************************************
         SIMLABM1
*
***********************************************************************
* Macro generated code that creates and uses generated labels.        *
*                                                                     *
* The advantage to this approach is the macro may be used more        *
* than once in the same program.                                      *
*                                                                     *
* The disadvantage to this approach is that it attempts to create     *
* unique labels but there is a possibility that a label may be        *
* generated that is the same as another label used in the program.    *
*                                                                     *
* Another disadvantage is that it uses &SYSNDX that provides a        *
* four digit number that is incremented. If the macro is used more    *
* that once in a program and the second use of the macro is placed    *
* before the original use of the macro then the name will be          *
* changed because the number portion will be incremented.             *
*                                                                     *
* Also, the labels that are generated will appear in the symbol       *
* table and may be confusing for the individual that uses the macro.  *
***********************************************************************
         SIMLABM2
*
***********************************************************************
* Macro generated code that avoids using labels.                      *
*                                                                     *
* The advantage of this approach is that it does not use any labels.  *
*                                                                     *
* The disadvantage to this approach is that it may be confusing since *
* the branch target is define as a numeric offset.                    *
*                                                                     *
* Also, care must be used when inserting additional code between the  *
* branch instruction and the branch target.                           *
***********************************************************************
         SIMLABM3
*
***********************************************************************
* Macro generated code with alignment considerations.                 *
*                                                                     *
* It is never that easy. Let's take a look at a realistic example.    *
* This program will pass a quoted text string to the macro. It is     *
* the macro's responsibility to maintain halfword alignment.          *
*                                                                     *
* This is easy to do as long as the quoted text string is an even     *
* number of characters. However, if the quoted text string is an odd  *
* number of characters the macro must do a little extra work.         *
*                                                                     *
* The following illustrates the techniques used to maintain the       *
* halfword alignment. The SR 15,15 instruction will be on a halfword  *
* boundary for both an even and odd length message.                   *
***********************************************************************
         SIMLABM4  'SIMLABM4, ALIGNMENT CONSIDERATIONS, EVEN'
*
         SIMLABM4  'SIMLABM4, ALIGNMENT CONSIDERATIONS, ODD'
*
***********************************************************************
         SR    15,15             * Set Return Code to Zero.
         BR    14                * Return to Caller
*
         END

Table of Contents Previous Section Next Section Macro with Branch & Labels

The following examples will show how to use Macro Files that will generate code with Branch Instructions and unique labels.

Table of Contents Previous Section Next Section Branch with a Specified Label

Using explicit names in the mainline code creates code that is simple and easy to understand. Using explicit labels in expanded macro code has the same advantage being that it is simple and easy to understand. The disadvantage of this approach is that the macro can only be used once in a program. A second use of this macro in the same program will cause a duplicate label error. The following macro (SIMLABM1.mac) uses explicit, hard-coded label names.

         MACRO
         SIMLABM1
.**********************************************************************
.*              SIMLABM1.MAC - This is an HLASM Macro                 *
.*                 Provided by SimoTime Technologies                  *
.*           (C) Copyright 1987-2019 All Rights Reserved              *
.*             Web Site URL:   http://www.simotime.com                *
.*                   e-mail:   helpdesk@simotime.com                  *
.**********************************************************************
.*
.* The following BAL instruction will branch around the Define Constant
.* (DC) that follows the instruction.
.*
.* The branch target label is explicitly defined.
.*
.* This macro may only be used once in a program. A second use
.* would cause a duplicate label error message.
.*

         BAL   1,HARDROCK        * Branch Target is specific label.
         DC    AL2(4+32,0)
         DC    CL32'SIMLABM1, USE A SPECIFIED LABEL.'
         DS    0H                * Maintain halfword alignment
HARDROCK SVC   35
.*
         MEND

Table of Contents Previous Section Next Section Branch with a Generated Label

The advantage to this approach is the macro may be used more than once in the same program. The disadvantage to this approach is that it attempts to create unique labels but there is a possibility that a label may be generated that is the same as another label used in the program.

Another disadvantage is that it uses &SYSNDX that provides a four digit number that is incremented. If the macro is used more that once in a program and the second use of the macro is placed before the original use of the macro then the name will be changed because the number portion will be incremented.

Also, the labels that are generated will appear in the symbol table and may be confusing for the individual that uses the macro. The following macro (SIMLABM2.mac) uses generated label names.

         MACRO
         SIMLABM2
.**********************************************************************
.*              SIMLABM2.MAC - This is an HLASM Macro                 *
.*                 Provided by SimoTime Technologies                  *
.*           (C) Copyright 1987-2019 All Rights Reserved              *
.*             Web Site URL:   http://www.simotime.com                *
.*                   e-mail:   helpdesk@simotime.com                  *
.**********************************************************************
.*
.* The following BAL instruction will branch around the Define Constant
.* (DC) that follows the instruction.
.*
.* The branch target label is generated by concatenating the literal
.* value of "ZLRS" with the numeric value supplied by $SYSNDX.
.*
.* This is an attempt to create and use a unique label within the
.* generated code. Once again, this is an attempt and in larger
.* programs the possiblity of generating a duplicate label increases.
.*

         BAL   1,ZLRS&SYSNDX        * Branch Target ZLRS plus &SYSNDX
         DC    AL2(4+32,0)
         DC    CL32'SIMLABM2, USE A GENERATED LABEL.'
         DS    0H                * Maintain halfword alignment
ZLRS&SYSNDX SVC   35
.*
         MEND

Table of Contents Previous Section Next Section Branch without a Label

The advantage of this approach is that it does not use any labels. The disadvantage to this approach is that it may be confusing since the branch target is define as a numeric offset. Also, care must be used when inserting additional code between the branch instruction and the branch target. The following macro (SIMLABM3.mac) avoids the use of label names.

         MACRO
         SIMLABM3
.**********************************************************************
.*              SIMLABM3.MAC - This is an HLASM Macro                 *
.*                 Provided by SimoTime Technologies                  *
.*           (C) Copyright 1987-2019 All Rights Reserved              *
.*             Web Site URL:   http://www.simotime.com                *
.*                   e-mail:   helpdesk@simotime.com                  *
.**********************************************************************
.*
.* The following BAL instruction will branch around the Define Constant
.* (DC) that follows the instruction.
.*
.* The *+4 item takes the current address of the BAL instruction
.* location and increments the branch target address by four.
.*
.* The second +4 increments past the control information.
.*
.* The +44 then increments the branch target address by forty-four,
.* the length of the message text..
.*
.* Note: some instructions require halfword alignment so the length
.* of the DC should always be an even number.
.*
         BAL   1,*+4+4+44        * Branch around literal.
         DC    AL2(4+44,0)
         DC    CL44'SIMLABM3, NO LABELS SPECIFIED OR GENERATED. '
         SVC   35
.*
         MEND

Table of Contents Previous Section Next Section Provides for Alignment Considerations

It is never that easy. Let's take a look at a realistic example. The program (SIMLABA1) will pass a quoted text string to the macro. It is the macro's responsibility to maintain halfword alignment.

This is easy to do as long as the quoted text string is an even number of characters. However, if the quoted text string is an odd number of characters the macro must do a little extra work. The following macro (SIMLABM4.mac) avoids using label names and will maintain halfword alignment.

         MACRO
         SIMLABM4 &MSG
.**********************************************************************
.*              SIMLABM4.MAC - This is an HLASM Macro                 *
.*                 Provided by SimoTime Technologies                  *
.*           (C) Copyright 1987-2019 All Rights Reserved              *
.*             Web Site URL:   http://www.simotime.com                *
.*                   e-mail:   helpdesk@simotime.com                  *
.**********************************************************************
.*
.* This macro will accept a quoted text string as a parameter.
.* This macro will calculate the length of the quoted text string
.* and maintain halfword alignment for the SVC 35 instruction. If
.* the quoted text string is an odd number of bytes then a pad
.* character is added to maintain the alignment.
.*
&MSGLEN  SETA  K'&MSG-2
&ALIGN   SETA  (K'&MSG-2)/2*2
         AIF   (&ALIGN NE &MSGLEN).ALIGNME
.*
.* The following BAL instruction will branch around the control
.* information and message text.
.*
         BAL   1,*+4+4+&MSGLEN     * Branch around literal.
         DC    AL2(&MSGLEN+4)
         DC    AL2(0)
         DC    C&MSG
         SVC   35                  * Maintain halfword alignment
         AGO   .END
.*
.ALIGNME ANOP
         BAL   1,*+4+4+&MSGLEN+1   * Branch around literal and pad.
         DC    AL2(&MSGLEN+4)
         DC    AL2(0)
         DC    C&MSG
         DC    CL1' '              * Pad for alignment
         SVC   35                  * Maintain halfword alignment
.*
.END     ANOP
         MEND

Table of Contents Previous Section Next Section Summary

The task of maintaining unique labels presented a bigger problem when using macros that generated code that included branch instructions. There are various techniques used to solve this problem and each has its own advantages and disadvantages. This document mat be used to assist as a tutorial for new programmers or as a quick reference for experienced programmers.

In the world of programming there are many ways to solve a problem. This documentation and software were developed and tested on systems that are configured for a SIMOTIME environment based on the hardware, operating systems, user requirements and security requirements. Therefore, adjustments may be needed to execute the jobs and programs when transferred to a system of a different architecture or configuration.

SIMOTIME Services has experience in moving or sharing data or application processing across a variety of systems. For additional information about SIMOTIME Services or Technologies please contact us using the information in the  Contact or Feedback  section of this document.

Table of Contents Previous Section Next Section Software Agreement and Disclaimer

Permission to use, copy, modify and distribute this software, documentation or training material for any purpose requires a fee to be paid to SimoTime Technologies. Once the fee is received by SimoTime the latest version of the software, documentation or training material 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 Technologies.

SimoTime Technologies makes no warranty or representations about the suitability of the software, documentation or learning material for any purpose. It is provided "AS IS" without any expressed or implied warranty, including the implied warranties of merchantability, fitness for a particular purpose and non-infringement. SimoTime Technologies 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, documentation or training material.

Table of Contents Previous Section Next Section Downloads and Links

This section includes links to documents with additional information that are beyond the scope and purpose of this document. The first group of documents may be available from a local system or via an internet connection, the second group of documents will require an internet connection.

Note: A SimoTime License is required for the items to be made available on a local system or server.

Table of Contents Previous Section Next Section Current Server or Internet Access

The following links may be to the current server or to the Internet.

Link to Internet   Link to Server   Explore the Assembler Connection for more examples of mainframe Assembler programming techniques and sample code.

Link to Internet   Link to Server   Explore an Extended List of Software Technologies that are available for review and evaluation. The software technologies (or Z-Packs) provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.

Link to Internet   Link to Server   Explore The ASCII and EBCDIC Translation Tables. These tables are provided for individuals that need to better understand the bit structures and differences of the encoding formats.

Link to Internet   Link to Server   Explore The File Status Return Codes that are used to interpret the results of accessing VSAM data sets and/or QSAM files.

Table of Contents Previous Section Next Section Internet Access Required

The following links will require an internet connect.

This suite of programs and documentation is available to download for review and evaluation purposes. Other uses will require a SimoTime Software License. Link to an Evaluation zPAK Option that includes the program members, documentation and control files.

A good place to start is The SimoTime Home Page for access to white papers, program examples and product information. This link requires an Internet Connection

Explore The Micro Focus Web Site for more information about products (including Micro Focus COBOL) and services available from Micro Focus. This link requires an Internet Connection.

Table of Contents Previous Section Next Section Glossary of Terms

Link to Internet   Link to Server   Explore the Glossary of Terms for a list of terms and definitions used in this suite of documents and white papers.

Table of Contents Previous Section Next Section Comments or Feedback

This document was created and is maintained by SimoTime Technologies. If you have any questions, suggestions, comments or feedback please use the following contact information.

1. Send an e-mail to our helpdesk.
1.1. helpdesk@simotime.com.
2. Our telephone numbers are as follows.
2.1. 1 415 763-9430 office-helpdesk
2.2. 1 415 827-7045 mobile

 

We appreciate hearing from you.

Table of Contents Previous Section Next Section Company Overview

SimoTime Technologies was founded in 1987 and is a privately owned company. 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. Our customers include small businesses using Internet technologies to corporations using very large mainframe systems.

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. We specialize in preparing applications and the associated data that are currently residing on a single platform to be distributed across a variety of platforms.

Preparing the application programs will require the transfer of source members that will be compiled and deployed on the target platform. The data will need to be transferred between the systems and may need to be converted and validated at various stages within the process. SimoTime has the technology, services and experience to assist in the application and data management tasks involved with doing business in a multi-system environment.

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
Labels and Mainframe Assembler Macro Usage
Copyright © 1987-2025
SimoTime Technologies and Services
All Rights Reserved
When technology complements business
http://www.simotime.com