View previous topic :: View next topic
|
Author |
Message |
surya.kalyan
New User
Joined: 09 Jan 2007 Posts: 20 Location: Mumbai
|
|
|
|
I have seen this store statement as the first statement of many assembler programs and at times it comes within the macros.
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
surya.kalyan
New User
Joined: 09 Jan 2007 Posts: 20 Location: Mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
R13 (Register 13) typically points to a register save area. R13 is typically not the base register. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|