Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:28:58+00:00 2026-06-03T05:28:58+00:00

I have been trying to create a Main program that calls another program, sending

  • 0

I have been trying to create a Main program that calls another program, sending it two variables. The called program then is supposed to open an output file and print the passed variables to output file, then return control to Main program.

I have created the Main program and the Sub-Program. They both compile without errors. The sub program works as stand alone program, but when I run Main program, the program branches to sub program and then fails when it tries to open the Output file.

The code is as follows. Any input on what I have done wrong would be greatly appreciated. Thank you.
CALLING PROGRAM:

         MAIN     START 0
         PRINT NOGEN        SUPPRESS GENERATED INSTRUCTIONS
         STM   14,12,12(13)
         BALR  12,0
         USING *,12

     MVC   MONTH1,=C'March'     
     MVC   MONTH2,=C'June'
     LA    9,=A(MONTH1,MONTH2)  Parameters to pass stored in R9
     SR    1,1
     LOAD  EP='SEARCH.COM'
     ST    13,SAVMAIN+4

     LA    13,SAVMAIN
     LR    15,0
     BALR  14,15
     WTO   'Subprogram was successful in finding data passed'

     RETURNPT WTO   'AND IT RETURNED'

     RETURN 

     MONTH1   DS    CL12        
     MONTH2   DS    CL12
     DS   0F
     SAVMAIN  DS  18F

     END   MAIN

CALLED PROGRAM:

SEARCH START 0
REGS
PRINT NOGEN SUPPRESS GENERATED INSTRUCTIONS
STM R14,R12,12(R13)
BALR R12,R0
USING *,R12 Set base register to R12
ST R13,SAVE+4
LA R13,SAVE
WTO 'SUB PROGRAM REACHED'
********
* Or Immediate files for reading and writing. Needed only on PC/370
********
OI OUTPUT+10,X'08'
WTO 'OI PROCESSED'
********
* Open all files needed for programming assignment
********
OPEN OUTPUT
WTO 'OUTPUT FILE OPENED'
*
*********************************************************
*** MAIN CODE ***
*********************************************************
*
L R8,0(R0,R9)
MVC FIND1,0(R8)
L R8,4(R0,R9)
MVC FIND2,0(R8)

WTO FIND1
WTO FIND2

MVC CTEMP,FIND1
MVC OWORD,=C'WORD 1:'
PUT OUTPUT,OREC

MVC CTEMP,FIND2
MVC OWORD,=C'WORD 2:'
PUT OUTPUT,OREC
*
*********************************************************
*** EOJ PROCESSING ***
*********************************************************
*
********
* Close all files needed for programming assignment
********
*
ATEND EQU *
CLOSE OUTPUT
WTO 'Subprogram was successful in printing passed data'

*********************************************************
*** END PROGRAM ***
*********************************************************
*
EXIT EQU *
RETURN

LTORG
*********************************************************
**** FILE DEFINITIONS ***
*********************************************************
OUTPUT DCB LRECL=29,RECFM=F,MACRF=P,DDNAME='MAINOUT.TXT'

OREC DS 0CL29
OWORD DS CL12
DC CL3' '
ORESULT DS CL12
DC X'0D25'

FIND1 DS CL12
FIND2 DS CL12
CTEMP DS CL12

DS 0F
SAVE DS 18F
END SEARCH

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:28:59+00:00Added an answer on June 3, 2026 at 5:28 am

    I realized that this question has remained unanswered. I finally figured out how to correctly perform Assembly program linkage in PC-370.

    The output is commented, for the most part. I give this code in hopes of helping another student deal with this concept.

    If someone comes across this and finds an error in the logic, please PM me and I will fix it.

    I hope this helps those in need.

    SUBCAN

    This is the MAIN.MLC program that calls the SUBPRG.MLC program.

    *******************************************************************
    *        FILENAME  :  MAIN.MLC                                    *
    *        AUTHOR    :  Subcan                                      *
    *        PROFESSOR :  X                                           *
    *        SYSTEM    :  ASUS P8Z68-Vpro w/I7-2600k CPU, PC/370 R4.2 *
    *        SYSTEM    :  ASUS P8Z68-Vpro w/I7-2600k CPU, PC/370 R4.2 *
    *        REMARKS   :  Coding two programs. A Main program and a   *
    *                     Subprogram. The main program will establish *
    *                     itself without using BEGIN, START, OR RETURN*
    *                     Macros. The main program will define two    *
    *                     Parameters to be passed to the subprogram.  *
    *                     The subprogram will then print these        *
    *                     parameters to an output file, then return   *
    *                     control back to calling program             *
    *******************************************************************
    *********************************************************
    ***                 PROGRAM ENTRY POINT               ***
    *********************************************************
    *
    MAIN     CSECT
             PRINT NOGEN        SUPPRESS GENERATED INSTRUCTIONS
             REGS
             STM   14,12,12(13)
             BASR  12,0
             USING *,12
             ST    13,SAVMAIN+4
             LA    13,SAVMAIN
    *
    *********************************************************
    ***                 MAIN CODE                         ***
    *********************************************************
    *
    ************
    * Load passing parameters to respective variables
    ************
             MVC   PARAM1,=CL12'March'      
             MVC   PARAM2,=CL12'June'
    ************
    * Load address of SUBPRG.COM into R1 then perform SVC 25
    * load parameter addresses into R1 to pass to called program
    ************
             LA    R1,=C'SUBPRG.COM'
             SVC   25                   Load file
             LR    15,0
             LA    15,X'0210'(0,15)
             LA    R1,=A(PARAM1,PARAM2)
    
             LA    R2,=C'LOADED PARAMETERS TO R1$'
             SVC   209                  Write to operator
    
             BALR  R14,R15              Branch to SUBPRG
    
             LA    R2,=C'And it returned$'
             SVC   209                  Write to operator
    *        
    *********************************************************
    ***                 END PROGRAM                       ***
    *********************************************************
    *
             L     R13,SAVMAIN+4
             LM    R14,R12,12(R13)  
             LA    R15,0
             BR    R14
    *
    *********************************************************
    ***                 ANY LITERALS                      ***
    *********************************************************
    *
             LTORG
    *
    *********************************************************
    ***                 OUTPUT FIELD DEFINITIONS          ***
    *********************************************************
    *
    PARAMS   DS   0F     
    PARAM1   DS    CL12     
    PARAM2   DS    CL12
    *
    *********************************************************
    ***                 RETURN ADDRESSES                  ***
    *********************************************************
    *
             DS   0F
    SAVMAIN  DS  18F
    
             END   MAIN
    

    This is the called program, SUBPRG.MLC

    *******************************************************************
    *        FILENAME  :  SUBPRG.MLC                                  *
    *        AUTHOR    :  Subcan                                      *
    *        PROFESSOR :  X                                           *
    *        SYSTEM    :  ASUS P8Z68-Vpro w/I7-2600k CPU, PC/370 R4.2 *
    *        REMARKS   :  Coding two programs. A Main program and a   *
    *                     Subprogram. The main program will establish *
    *                     itself without using BEGIN, START, OR RETURN*
    *                     Macros. The main program will define two    *
    *                     Parameters to be passed to the subprogram.  *
    *                     The subprogram will then print these        *
    *                     parameters to an output file, then return   *
    *                     control back to calling program             *
    *******************************************************************
    *********************************************************
    ***                 PROGRAM ENTRY POINT               ***
    *********************************************************
    *
    SUBPRG   CSECT
             REGS
             PRINT NOGEN        SUPPRESS GENERATED INSTRUCTIONS
             STM   14,12,12(13)
             BASR  12,0
             USING *,12
             ST    13,SAVE+4
             LA    13,SAVE
    *
    *********************************************************
    ***                 MAIN CODE                         ***
    *********************************************************
    * 
             LA    R2,=C'Sub program reached$'
             SVC   209                  Write to operator
    ************
    * Use the Assist Macros to perform open and writing of files
    * Look to PC-370 DOCS\USER.DOC for more info
    * XFILO - This extended instruction redirects the output from XPRNT.
    * XPRNT - Print record. Ends with ,length to set length of record.
    *           Character string always ends with $ to show end of line.
    ************
             XFILO =C'SUBOUT.TXT'
    
             LA    R2,=C'Output file opened$'
             SVC   209                  Write to operator
    
             L     R8,0(R1)
             MVC   PARAM1(12),0(R8)
             L     R8,4(R1)
             MVC   PARAM2(12),0(R8)
    
             XPRNT =CL51' The following are words passed by Calling Program.',51
             XPRNT =C'  ',2                 SKIP ONE LINE
             MVC   ORESULT,PARAM1
             MVC   OWORD,=CL12' WORD 1:'
             XPRNT OREC,27
    
             MVC   ORESULT,PARAM2
             MVC   OWORD,=CL12' WORD 2:'
             XPRNT OREC,27
    
             MVI   PARAM1+11,C'$'       MVI $ to provide end of line
             LA    R2,PARAM1
             SVC   209                  Write to operator
    
             MVI   PARAM2+11,C'$'       MVI $ to provide end of line    
             LA    R2,PARAM2
             SVC   209                  Write to operator
    
             LA    R2,=C'Subprogram was successful in printing passed data$'
             SVC   209                  Write to operator
    *        
    *********************************************************
    ***                 END PROGRAM                       ***
    *********************************************************
    *
    EXIT     EQU   *
             L     R13,SAVE+4
             LM    R14,R12,12(R13)  
             LA    R15,0
             BR    R14
    *
    *********************************************************
    ***                 ANY LITERALS                      ***
    *********************************************************
    *
             LTORG
    *
    *********************************************************
    ***                 OUTPUT FIELD DEFINITIONS          ***
    *********************************************************
    *
    OREC     DS   0F
    OWORD    DS    CL12
             DC    CL3' '
    ORESULT  DS    CL12
    *
    *********************************************************
    ***                 CHARACTER FIELD DEFINITIONS       ***
    *********************************************************
    *
    PARAM1   DS    CL12     
    PARAM2   DS    CL12
    *
    *********************************************************
    ***                 RETURN ADDRESSES                  ***
    *********************************************************
    *
             DS   0F
    SAVE     DS  18F
             END   SUBPRG
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to create a menu panel with jQuery that can be
I have been trying to create a simple program with Python which uses OpenCV
I have recently been trying to create an updater for my program. The updater
I have been trying to create a pointer variable in the called function and
I have been trying to create a new google custom search engine, but when
I have been trying to create an observable tweeter feed using tweetsharp with the
I have been trying to create an XML using the simplexml library (v2.6.2) http://simple.sourceforge.net/home.php
Hi I have been trying to create a crossfade plugin with previous and next
I have been trying to find a good guide to create a templated control.
Ok I'm stumped. I have been trying to use Simpletip to create a tooltip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.