Я понял, что этот вопрос остался без ответа. Наконец-то я разобрался, как правильно выполнить связывание программ сборки в PC-370.
Вывод по большей части прокомментирован. Я даю этот код в надежде помочь другому студенту разобраться с этой концепцией.
Если кто-то сталкивается с этим и находит ошибку в логике, пожалуйста, напишите мне в личку, и я исправлю это.
Надеюсь, это поможет нуждающимся.
SUBCAN
Это программа MAIN.MLC, которая вызывает программу SUBPRG.MLC.
*******************************************************************
* 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
Это вызываемая программа, 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