Load object module in assembly using LOAD Module



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

Re: Load object module in assembly using LOAD Module

Postby dick scherrer » Wed Feb 02, 2011 9:03 am

Hello,

It is still not clear where you are "stuck". . .

See if this example from IBM will help:
http://publib.boulder.ibm.com/infocente ... 160414.htm

Don't focus on the specifics of the example, just on how the LOAD and later CALL are coded.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Load object module in assembly using LOAD Module

Postby steve-myers » Wed Feb 02, 2011 9:11 am

belkin99 wrote:Good Catch,

This is Using Assembler with a "Load macro" to load & execute the "load module" that created in JCL steps.
Thats all Folks
//        EXEC PGM=program-name
is the usual way to run a program from JCL. There is no need for am intermediate program.

Your question of what your program should do next does not have an answer we can readily divine. Many of us would suggest that you should DELETE the loaded program if your program is going to do something significant.
RUNPGM   CSECT
         USING *,12
         SAVE  (14,12),,*
         LR    12,15
         LA    15,SAVEAREA
         ST    15,8(,13)
         ST    13,4(,15)
         LR    13,15
         LR    2,1
         LOAD  EP=program-name
         LR    15,0
         LR    1,2
         BALR  14,15
         L     13,4(,13)
         RETURN (14,12),T,RC=(15)
SAVEAREA DC    9D'0'
         END   RUNPGM
This has not been tested in any way, but if you replace the string program-name with the name of a real program this program would load and run it, subject to the concerns about the AMODE and RMODE I mentioned before.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Load object module in assembly using LOAD Module

Postby Robert Sample » Wed Feb 02, 2011 9:22 am

I am asking if is there any example showing how to load object module in the Assembly. Using LOAD module."
The answer to your question is yes. The z/OS V1R9.0 MVS Assembler Services Reference (IAR-XCT) SA22-7607-12 manual, for example (other versions of z/OS have the same manual but the reference number would not be -12), has examples of the LOAD macro and describes its use.

By the way, merely repeating your earlier post -- word for word -- without attempting to explain what you meant is not helpful. Restating a concept using different words may impart understanding that merely repeating won't. If you cannot find other words to explain what you're wanting, then perhaps you do not understand the concept well enough to ask a good question about it.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Load object module in assembly using LOAD Module

Postby steve-myers » Wed Feb 02, 2011 6:17 pm

I'm giving the original poster a freebie he does not deserve. There are no comments so the original poster can figure out for himself how the program works, though I will answer questions. Rather than get into trouble with the AMODE/RMODE conflicts possible with the original caller's idea of using LOAD and CALL, this program uses the LINK macro which will handle AMODE/RMODE conflicts and achieve the same result.
* RUN A PROGRAM SPECIFIED IN THE JCL EXEC STATEMENT PARM TEXT
* // EXEC PGM=RUNPGM,PARM='PROGRAM/PARM TEXT FOR PROGRAM'
RUNPGM   CSECT
         USING *,12
         SAVE  (14,12),,*
         LR    12,15
         LA    15,SAVEAREA
         ST    15,8(,13)
         ST    13,4(,15)
         LR    13,15
         L     2,0(,1)
         LH    5,0(,2)
         LA    5,1(5,2)
         LA    4,1
         LA    3,2(,2)
         LR    14,3
GETNAME  CLI   0(3),C'/'
         BE    GOTNAME
         BXLE  3,4,GETNAME
GOTNAME  LR    15,3
         SR    15,14
         BP    MOVENAME
         ABEND 1,DUMP
MOVENAME C     15,=F'8'
         BNH   MOVEPGM
         ABEND 2,DUMP
MOVEPGM  BCTR  15,0
         EX    15,COPYPGM
         BXH   3,4,NOPARM
         LA    15,1(,5)
         SR    15,3
         BNP   NOPARM
         STH   15,PARMLEN
         BCTR  15,0
         EX    15,COPYPARM
NOPARM   LINK  EPLOC=PGMNAME,PARAM=PARMLEN,VL=1
         L     13,4(,13)
         RETURN (14,12),T,RC=(15)
COPYPGM  MVC   PGMNAME(*-*),0(14)
COPYPARM MVC   PARMTEXT(*-*),0(3)
SAVEAREA DC    9D'0'
PGMNAME  DC    CL8' '
PARMLEN  DC    H'0'
PARMTEXT DC    CL100' '
         END   RUNPGM
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Load object module in assembly using LOAD MACRO

Postby belkin99 » Wed Feb 23, 2011 7:09 am

Thanks Guys for all these rich information,

Finally, I would like to put what I learned
The Load Macro is a type of the SVC (supervisor Call) which allow to load LOAD Module or/and OBJECT module and/or Control statement into virtual storage.
But LOAD macro does not pass the control to the LOAD module, instead its get the EP (symbolic name of the entry point of the LOAD module) in R0. If there are
parameter list need to be pass to the LOAD module, R1 should point at them.

Finally, R15 will be 0, if the LOAD macro was success in the operation.
belkin99
 
Posts: 25
Joined: Mon Aug 30, 2010 6:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Load object module in assembly using LOAD Module

Postby belkin99 » Wed Feb 23, 2011 7:26 am

Just I forget one thing,
To call the LOAD module, you will be able to use BAL
belkin99
 
Posts: 25
Joined: Mon Aug 30, 2010 6:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Load object module in assembly using LOAD MACRO

Postby steve-myers » Wed Feb 23, 2011 8:33 am

belkin99 wrote:... Finally, I would like to put what I learned
The Load Macro is a type of the SVC (supervisor Call) which allow to load LOAD Module or/and OBJECT module and/or Control statement into virtual storage ...

The LOAD macro will load a load module or "program object" into storage. It will not load an object module or any related control statements that are typically intended for the Binder or Linkage Editor. A "program object" is a load module located in a PDSE dataset. An "object module" is the binary output from an Assembler or compiler, and is usually expressed as 80 byte logical records that have X'02' in the first byte of each record.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Load object module in assembly using LOAD Module

Postby belkin99 » Fri Feb 25, 2011 6:58 am

To steve-myers,

Thank you for correction my misunderstanding, this is the reason that we have an expert people in this forum.

Thanks guys.
belkin99
 
Posts: 25
Joined: Mon Aug 30, 2010 6:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Load object module in assembly using LOAD MACRO

Postby steve-myers » Sat Feb 26, 2011 11:30 pm

belkin99 wrote:... Finally, R15 will be 0, if the LOAD macro was success in the operation.

Generally speaking, if the LOAD macro fails it will generate an ABEND. The only exception is if you specify ERRET, when LOAD will return with 0 in reg 15 if it loaded the module, and something else in reg 15 if it failed. Even then, the LOAD macro will branch to the error routine specified by the ERRET parameter.

In other words, there is no real reason to check reg 15 after a LOAD macro in your code. LOAD without ERRET will never return to your code if it failed; LOAD with ERRET will not return to the instruction following the LOAD if it failed.

This is actually kind of unfortunate. MVS Assembler Services Reference IAR-XCTL clearly states reg 15 will be 0. It then describes reg 15 and reg 1 if ERRET is specified
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Load object module in assembly using LOAD Module

Postby steve-myers » Tue Mar 01, 2011 10:03 am

belkin99 wrote:Just I forget one thing,
To call the LOAD module, you will be able to use BAL

Well, usually BALR or BASR, though a properly coded BAL or BAS would work.

LOAD EP=THEPGM
LR 15,0
LA 1,PARMLIST
BALR 14,15 or BAL 14,0(0,15) or BASR 14,15 or BAS 14,0(0,15)

Most experienced Assembler programmers would use

LOAD EP=THEPGM
LR 15,0
CALL (15),MF=(E,PARMLIST)

The CALL macro, as coded, generates the LA and BALR instructions. Notice that reg 15 is not tested after the LOAD macro.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Previous

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post