Open and put macro with external sub routine



High Level Assembler(HLASM) for MVS & VM & VSE

Open and put macro with external sub routine

Postby eaglei22 » Tue Mar 13, 2012 3:30 am

Hello, I keep getting an error that says no active using statement for the put macro when I call it in an external routine.
This is my first time using the open and put macro so I'm sure I'm overlooking something simple.


code snipit
MAIN CSECT
****************************************************************
* *
****************************************************************
* <1> * STANDARD ENTRY LINKAGE ***
         STM   R14,R12,12(R13)
         LR    R12,R15
         USING MAIN,R12
         LA    R14,MAINSAVE
         ST    R13,4(,R14)
         ST    R14,8(,R13)
         LR    R13,R14
* <2> * OPEN DCBS AND VERIFY SUCCESSFUL OPENS
         OPEN (QPRNT,(OUTPUT))
         IF   (LTR,R15,R15,NZ)
           B     SABEND1
         ENDIF
* <3>* DRIVER **
       ESPIE SET,ESPIEXT,(1,(5,7),9,13),PARAM=PARMLIST
*
* <> ***SET TIMER OPERATIONS*****
       L  R15,=V(TMREXIT)
       STIMER TASK,(R15),BINTVL=INTV1   
*
*
* <> * CLOSE DCBS AND EXIT
         CLOSE (QPRNT)
* <> * Restore Registers and Return.
         L     R13,4(R13)
         LM    R14,R12,12(R13)
         BR    R14
         LTORG
**************************************************
*       STORAGE FOR MAIN                         *
**************************************************
MAINSAVE DS    18F
SABEND1  ABEND 100,DUMP
PARMLIST DC    A(STRING,ADDR)
STRING   DC    C'EXIT'
ADDR     DS    A(0)
*
INTV1    DS F
         DC X'00000BB8'
*****
*****
**************************************************
*       TIMER EXIT ROUTINE                       *
**************************************************
TMREXIT CSECT
       STM   R14,R12,12(R13)  SAVES ALL CALLING REGS EXCEPT R13
       LR    R12,R15            LOADS ADDRESS OF TMREXIT INTO R12
       USING TMREXIT,R12     SETS R12 AS BASE REGISTER
       LA    R14,TSAVE       WHERE REGISTERS ARE STORED WHEN CALL
       ST    R13,4(R14)         BACKWARD POINTER STORED
       ST    R14,8(R13)         FORWARD POINTER STORED
       LR    R13,R14            R13 POINTED TO BUILDS SAVE AREA
*
       PUT   QPRNT,TIMERPRNT   
******BACK TO MAIN*************
        L     R13,4(R13)       LOADS ADDRESS OF CALLING ROUTINE REGS
        LM    R14,R12,12(R13)  LOADS REGISTERS
        BR    R14              RETURN CONTROL   
**************************************************
*       TIMER EXIT STORAGE                       *
**************************************************
*
            LTORG
TSAVE       DS    18F
TIMERPRNT   DC    CL17'Timer has expired'



error:
                                   
975 ****************************************************************                           
                                    976 * *                                                                                         
                                    977 ****************************************************************                           
                                    978 * <1> * STANDARD ENTRY LINKAGE ***                                                         
000000 90EC D00C            0000C   979          STM   R14,R12,12(R13)                                                             
000004 18CF                         980          LR    R12,R15                                                                     
                 R:C  00000         981          USING MAIN,R12                                                                     
000006 41E0 C074            00074   982          LA    R14,MAINSAVE                                                                 
00000A 50D0 E004            00004   983          ST    R13,4(,R14)                                                                 
00000E 50E0 D008            00008   984          ST    R14,8(,R13)                                                                 
000012 18DE                         985          LR    R13,R14                                                                     
                                    986 * <2> * OPEN DCBS AND VERIFY SUCCESSFUL OPENS                                               
000014 4510 C01C            0001C   987          OPEN (QPRNT,(OUTPUT))                                                             
00001E 12FF                         993          IF   (LTR,R15,R15,NZ)                                                             
000024 47F0 C0BC            000BC  1004            B     SABEND1                                                                   
                                   1005          ENDIF                                                                             
                                   1008 * <3>* DRIVER **                                                                           
000028 4D10 C03C            0003C  1009        ESPIE SET,ESPIEXT,(1,(5,7),9,13),PARAM=PARMLIST                                     
                                   1022 *                                                                                           
                                   1023 * <> ***SET TIMER OPERATIONS*****                                                           
000046 58F0 C070            00070  1024        L  R15,=V(TMREXIT)                                                                   
00004A 4110 C0DC            000DC  1025        STIMER TASK,(R15),BINTVL=INTV1                                                       
                                   1033 *                                                                                           
                                   1034 *                                                                                           
                                   1035 * <> * CLOSE DCBS AND EXIT                                                                 
00005A 0700                        1036          CLOSE (QPRNT)                                                                     
                                   1042 * <> * Restore Registers and Return.                                                       
000066 58DD 0004            00004  1043          L     R13,4(R13)                                                                   
00006A 98EC D00C            0000C  1044          LM    R14,R12,12(R13)                                                             
00006E 07FE                        1045          BR    R14                                                                         
000070                             1046          LTORG                                                                             
000070 00000000                    1047                =V(TMREXIT)                                                                 
                                   1048 **************************************************                                         
                                   1049 *       STORAGE FOR MAIN                         *                                         
                                   1050 **************************************************                                         
000074                             1051 MAINSAVE DS    18F                                                                         
0000BC 4110 0064            00064  1052 SABEND1  ABEND 100,DUMP                                                                     
0000CC 000000D4000000D8            1062 PARMLIST DC    A(STRING,ADDR)                                                               
0000D4 C5E7C9E3                    1063 STRING   DC    C'EXIT'                                                                     
0000D8                             1064 ADDR     DS    A(0)                                                                         
                                   1065 *                                                                                           
0000DC                             1066 INTV1    DS F                                                                               
0000E0 00000BB8                    1067          DC X'00000BB8'                                                                     
                                   1068 *****                                                                                       
                                   1069 *****                                                                                       
                                   1070 **************************************************                                         
                                   1071 *       TIMER EXIT ROUTINE                       *                                         
                                   1072 **************************************************                                         
0000E8                000E8 00089  1073 TMREXIT CSECT                                                                               
0000E8 90EC D00C            0000C  1074        STM   R14,R12,12(R13)  SAVES ALL CALLING REGS EXCEPT R13                             
i0000EC 18CF                        1075        LR    R12,R15            LOADS ADDRESS OF BUILD INTO R12                             
                                                                                                               Page    4           
  Active Usings: TMREXIT,R12                                                                                                       
  Loc  Object Code    Addr1 Addr2  Stmt   Source Statement                                  HLASM R6.0  2012/03/12 17.13           
                 R:C  000E8        1076        USING TMREXIT,R12     SETS R12 AS BASE REGISTER                                     
0000EE 41E0 C030            00118  1077        LA    R14,TSAVE       WHERE REGISTERS ARE STORED WHEN CALL                           
0000F2 50DE 0004            00004  1078        ST    R13,4(R14)         BACKWARD POINTER STORED                                     
0000F6 50ED 0008            00008  1079        ST    R14,8(R13)         FORWARD POINTER STORED                                     
0000FA 18DE                        1080        LR    R13,R14            R13 POINTED TO BUILDS SAVE AREA                             
                                   1081 *                                                                                           
                                   1082        PUT   QPRNT,TIMERPRNT                                                               
0000FC 0000 0000            00000  1084+         LA    1,QPRNT                           LOAD PARAMETER REG 1   02-IHBIN           
** ASMA307E No active USING for operand QPRNT                                                                                       
** ASMA435I Record 50 in SYS1.MACLIB(IHBINNRA) on volume: VTMVSC                                                                   
                                   1089 ******BACK TO MAIN*************                                                             
00010C 58DD 0004            00004  1090         L     R13,4(R13)       LOADS ADDRESS OF CALLING ROUTINE REGS                       
000110 98EC D00C            0000C  1091         LM    R14,R12,12(R13)  LOADS REGISTERS                                             
000114 07FE                        1092         BR    R14              RETURN CONTROL                                               
                                   1093 **************************************************                                         
                                   1094 *       TIMER EXIT STORAGE                       *                                         
                                   1095 **************************************************                                         
                                   1096 *                                                                                           
000118                             1097             LTORG                                                                           
000118                             1098 TSAVE       DS    18F                                                                       
000160 E389948599408881            1099 TIMERPRNT   DC    CL17'Timer has expired'                                                   
                                   1100 *                                                                                           
                                   1101 **************************************************                                         
                                   1102 *       EXIT ROUTINE                             *                                         
                                   1103 **************************************************                                         
000178                00178 00108  1104 ESPIEXT CSECT   
eaglei22
 
Posts: 8
Joined: Sat Jan 28, 2012 2:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: Open and put macro with external sub routine

Postby eaglei22 » Tue Mar 13, 2012 3:50 am

also here is the dcb i use for the qsam

QPRNT DCB DSORG=PS,MACRF=PM,BLKSIZE=121,LRECL=121,RECFM=FA,DDNAME=OUT
eaglei22
 
Posts: 8
Joined: Sat Jan 28, 2012 2:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: Open and put macro with external sub routine

Postby Robert Sample » Tue Mar 13, 2012 4:06 am

If QPRNT is defined in one CSECT, and you refer to it in another CSECT, just how are you ensuring addressability of QPRNT across the different CSECT? If your PUT statement is not in the same CSECT as the DCB, you'll need to either establish addressability to QPRNT in some way (which may defeat the purpose of a subroutine), or you'll need to use a register / offset to point to the DCB instead of a name.

If you treat a CSECT like a main program in COBOL or C (the analogy isn't perfect, but it'll do for a beginner), you'll have a better chance of writing code that stands a chance of working.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Open and put macro with external sub routine

Postby eaglei22 » Tue Mar 13, 2012 4:42 am

Thanks for the reply Robert,

can i just simply use a Load Address instruction and pass it that way? but then how do I interact the Put macro with the pointer to the dcb inside the external sub routine.
eaglei22
 
Posts: 8
Joined: Sat Jan 28, 2012 2:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: Open and put macro with external sub routine

Postby Robert Sample » Tue Mar 13, 2012 6:00 am

Have you looked at the DFSMS Macro Instructions for Data Sets manual? If not, you need to spend some serious time in it. If you have, then you should know already that you can use
PUT (R?),TIMERPRNT
where R? represents the register you are using for the DCB address.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Open and put macro with external sub routine

Postby steve-myers » Tue Mar 13, 2012 6:02 am

Before I start. ESPIE is for fairly advanced users. Stay away from it. In more than 44 years of writing /360 Assembler I can count on the fingers of one hand the number of times I've tried SPIE or ESPIE, and they are not used in any finished production program. It's not so much the ESPIE macro; the exit routines will kill you before you can make them do anything useful for you. 128-bit hexadecimal floating point was added to System/360 quite late in the game, just for the Model 85. IBM didn't bother to implement the 128-bit hexadecimal floating point instruction on the Model 85; though they did provide a macro for the division operation, and there was a provision to call the simulation code for division (or for all the 128-bit floating point operations on the other System/360 machines) through a user written SPIE (ESPIE did not yet exist) exit.

There is no conceptual problem putting a DCB in one CSECT and using it in another CSECT. I've done this with a large (1800+ line) program that is close to becoming a frozen production program that I'm working on now. There are two common ways to do this.
  • Use address constants.
    PGM1     CSECT
             ...
             L     1,=A(DCB)
             PUT   (1),DATA
             ...
    PGM2     CSECT
             ...
    DCB      DCB   ...
    Address constants are probably your only choice if the second CSECT is assembled independently of the first CSECT, in which case you would define the DCB as an entry point in the second program, and an external symbol in the first program.
  • Use ordinary addressability
    PGM1     CSECT
             ...
             USING PGM2,areg
             ...
             PUT   DCB,DATA
             ...
    PGM2     CSECT
             ...
    DCB      DCB   ...
    Setting up the base register for the second CSECT to be used in the first CSECT is an exercise for you.

    If you look into the expansion of a "regular" PUT macro you will discover it uses the LA instruction.
One issue you should avoid is trying to share the DCB with two concurrently executing subtasks, but that's certainly beyond your current skill set.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Open and put macro with external sub routine

Postby eaglei22 » Tue Mar 13, 2012 1:19 pm

That did the trick, thanks to both of you, the examples made sense of it.. and I didn't know that (R*) could be passed like that through put.
eaglei22
 
Posts: 8
Joined: Sat Jan 28, 2012 2:30 am
Has thanked: 0 time
Been thanked: 0 time

Re: Open and put macro with external sub routine

Postby steve-myers » Tue Mar 13, 2012 6:25 pm

eaglei22 wrote:That did the trick, thanks to both of you, the examples made sense of it.. and I didn't know that (R*) could be passed like that through put.
Your welcome.

Many IBM macros that provide operands that are defined as RX-type symbols can also use registers. An RX-type symbol is a symbol that defines storage that can be used in an RX type instruction. There are a few surprises, though, for example -

PUT DCB,=CL80'FIXED TEXT'

work just great. Of course, you can screw up, too -

PUT =CL8'DCB',=CL80'FIXED TEXT'

will go through the Assembler with no trouble, but you will not get good results if you try to execute the code!

R* symbols

For most of the 44+ years I've been writing /360 Assembler R* symbols were effectively required, not because there was anything magical about them, but because they were listed in the symbol XREF table the Assembler lists. Sometime in the 1990s the Assembler was altered to write the register XREF table, which is superior because it displays implied registers. For example -

TRT DATA,TABLE

potentially alters registers 1 and 2. These registers are shown in the new register XREF table. Like most of my collegues, I kept using R* symbols out of habit, but I no longer bother, simply because the register XREF table is much better than using R* symbols. For a while I'd use R* symbols sporadically, but didn't define them. Oops.

Another issue with R* symbols is, as an example, R1 might not be defined as R1 EQU 1, and this could lead to errors.

Another issue is in the 1960s, we were encouraged to use alias names for registers. The HASP program, for example defined registers like LINK1, LINK2, WA, WB and so on. Through the 1970s and 1980s this convention was quietly forgotten, and you rarely see alias names like these any more because they tend to be confusing.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post