HLASM - STH = STore Halfword

The opcode of the STH instruction is X'40'.

Usage

  1. Store a halfword from a register into storage.

Arguments

  1. Register containing value to be stored.
  2. Address where halfword is to be stored.

Function

  1. The low-order halfword in the register is stored at the address.
  2. The condition code does not change.

Special Cases

  1. None.

Related Instructions

  1. STHY stores a halfword using a 20-bit displacement, instead of the 12-bit displacement STH uses.
  2. ST stores a fullword.
  3. STC stores a single byte.
  4. STCM stores a set of bytes.
  5. LH loads a halfword from storage into a register.

Hardware

  1. All hardware supports the STH instruction.

Remarks

  1. On older hardware the storage location had to be an even address; using an odd address caused a S0C6 abend.
  2. Currently, an assembler diagnostic is still generated, but execution is fine; a non-aligned storage operand, however, may cause performance degradation.
  3. When coding a table with halfword entries, it is good coding practice to put them - whenever feasible - on halfword but not fullword boundaries. When loading or storing, if a L or ST is used incorrectly, an assembler diagnostic will be generated.

Examples

Notes on the example below:

  1. R14 is used as an index into the table.
  2. MVI would normally be used to initialize a single byte field, but MVI does not use an index register, and thus cannot be used here.
         YREGS                          * Define register names
         ...
* This is a routine to initialize a table
         LA    R15,0                    * Load table entry number (start=0)
         SR    R14,R14                  * R14 indexes into the table
         LA    R0,10                    * Load number of table entries
         LA    R1,C' '                  * Char flag for the table entry
INITLOOP STH   R15,TABLE#(R14)          * Store entry number
         STC   R1,FLAG(R14)             * Store char flag
         LA    R14,12(R14)              * Bump index into the table
         LA    R15,1(R15)               * Bump entry number
         BCT   R0,INITLOOP              * Loop through all 10 table entries
         ...
         DS    0F                       * Insure table has fullword alignment
TABLE    DS    0CL12                    * Indicate each entry is 12 bytes
         DC    F'0'                     *
FLAG     DC    C' '                     * Character flag
         DC    X'00'                    * Bit type flag
ENTRY#   DC    H'0'                     * Table entry number
         DC    A(0)                     *
         DC    9XL12'00'                * Rest of the table
         ...

To the Opcodes Overview.
To the English Homepage for Hlasm.com.
To the General Homepage for Bixoft and Hlasm.com.

This site is a member of WebRing.
You are invited to browse the list of mainframe-loving sites.
Running Tyrannosaurus Rex Dinos are not dead. They are alive and well and living in data centers all around you. They speak in tongues and work strange magics with computers. Beware the dino! And just in case you're waiting for the final demise of these dino's: remember that dinos ruled the world for 155-million years!
Dinos and other anachronisms
[ Join Now | Ring Hub | Random | << Prev | Next >> ]
 

Below you find the logo of our sponsor and logos of the web-standards that this page adheres to.