IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What is the the implication of STM 14,12,12(13) ?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
surya.kalyan

New User


Joined: 09 Jan 2007
Posts: 20
Location: Mumbai

PostPosted: Tue Mar 10, 2009 3:24 am
Reply with quote

I have seen this store statement as the first statement of many assembler programs and at times it comes within the macros.


Code:
 STM 14,12,12(13) 


What it is its implication? Usually in this case R13 is the base register.
We are storing the registers from 14 to 12 starting at the location pointed by 13.

But why do we do this?

It may be a simple qn. Kindly explain.

--------------
Kalyan.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Mar 10, 2009 3:26 am
Reply with quote

R13 is set by the calling program to the address of the register SAVEAREA

the STM instruction saves the registers according to the standard IBM convention
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 10, 2009 3:37 am
Reply with quote

Hello,

There is a method used by good assembler programmers called "standard linkage convention". This is a method for each bit of code to save the "caller's" registers upon entry and restore them when the code returns.

The STM is part of this method.
Back to top
View user's profile Send private message
surya.kalyan

New User


Joined: 09 Jan 2007
Posts: 20
Location: Mumbai

PostPosted: Wed Mar 11, 2009 1:44 am
Reply with quote

Hi Enrico,

I m sorry but I was not able to digest your reply.

Hi Scherrer,

I got your point, but why would someone leave out Reg 13?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 11, 2009 1:55 am
Reply with quote

Hello,

R13 (Register 13) typically points to a register save area. R13 is typically not the base register.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 11, 2009 3:28 am
Reply with quote

Hello again,

Here is a small example of some assembler that will show what we have been talking aobut (note that the SAVE and RETURN macros are used rather than straight code):
Code:
HELLOWLD START 0                  IN THE BEGINNING...
         PRINT NOGEN              SPARE US THE MACRO EXPANSIONS
BEGIN    SAVE  (14,12)            SAVE INPUT REGISTERS
         LR    12,15              WHERE ARE WE?
         USING HELLOWLD,12        RIGHT HERE
         ST    13,SAVE+4          SAVE OLD SAVE AREA ADDRESS
         LA    11,SAVE            POINT TO NEW SAVE AREA
         ST    11,8(13)           IN OLD SAVE AREA
         LR    13,11              MOVE SAVE AREA ADDRESS
*
* WRITE "HELLO, WORLD!" ON WHATEVER HAS BEEN SET UP AS SYSPRINT IN
*  THE INVOKING JCL
*
DOTHEPUT EQU   *
         PUT   SYSPRINT,HELLOMSG  WRITE THE MESSAGE
*
*
         L     13,SAVE+4          GET OLD SAVE AREA BACK
         RETURN (14,12),RC=0      TO THE OPERATING SYSTEM
*
* FILE AND WORK AREA DEFINITIONS
*
SAVE     DS    18F                LOCAL SAVE AREA
HELLOMSG DC    C' HELLO, WORLD!'
SYSPRINT DCB   DSORG=PS,MACRF=PM,DDNAME=SYSPRINT,                      X
               RECFM=FA,LRECL=133,BLKSIZE=133
         END   BEGIN
This is one of the many versions of the "Hello World" program that is a very simple way to prove to one's self that some new language is "working" for them. Suggest you assemble this and review the output of the assembly and then run the code to make sure it still works. I didn't get to assemble it before posting, but thought the example might be useful.

Note that while there are 16 registers, the save area is 18 full words. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts what is the implication of EBCDIC CC... DB2 1
Search our Forums:

Back to Top