
STM is used to copy a
“consecutive” collection of registers into consecutive fullwords in main
storage. The collection of registers
which is copied is specified by coding the beginning and ending registers as
the first two operands. For instance,
STM R5,R8,XWORDS
would be used to copy
registers 5, 6, 7, and 8. If the second
operand specifies a lower register than the first operand, then a “wrap-around”
occurs. For instance,
STM R14,R12,12(R13)
would be used to copy
registers 14, 15, 0, 1, ..., 12 - every register except 13.
The registers are stored starting in the fullword address
specified in the third operand. In the
first example above, register 5 would be stored at XWORDS, register 6 at
XWORDS+4, register 7 at XWORDS+8, and
register 8 at XWORDS+12. In the
second example, register 14 is stored at an explicit address - a 12 byte displacement off register 13. The other registers are consecutively
stored.
Here is an example.
STM R7,R9,REGWORDS

In the example above, the consecutive range of registers ( 7, 8,
and 9 ) are stored in consecutive fullwords in memory starting in the fullword
specified as REGWORDS.
Some Unrelated STM’s
XWORD
DS F
...
STM R5,R6,XWORD
XWORD = CONTENTS(R5)
XWORD+4 =
CONTENTS(R6)
STM R15,R1,XWORD
XWORD = CONTENTS(R15)
XWORD+4 =
CONTENTS(R0)
XWORD+8 =
CONTENTS(R1
STM R14,R12,12(R13) THIS STORES ALL REGISTERS EXCEPT 13
12 BYTES OFF REGISTER 13. SEE
THE TOPIC
ON PROGRAM LINKAGE

1) This statement is helpful for creating subroutines. Branch to a subroutine and immediately save
the registers with STM. This allows your subroutine to freely use
the registers. Before exiting your
subroutine, restore the registers with LM. Create a register “save area” for each
subroutine.
BAS R6,SUBRTN CALL THE
SUBROUTINE
...
SUBRTN EQU *
STM R14,R12,SUBSAVE SAVE
THE REGISTERS
... (SUBROUTINE CODE)
LM R14,R12,SUBSAVE
RESTORE THE REGISTERS
BR R6 BRANCH
BACK TO CALLER
SUBSAVE DS 15F FIFTEEN FULLWORDS FOR THE REGISTERS
2) Read about the role that STM plays in implementing the “linkage
conventions” in Program Linkage .