The USING pseudo-instruction is used to inform the assembler of the contents of various registers which are to be used in base-displacement addressing. It does not generate any executable instructions, it provides information to the assembler.
The format for the USING pseudo-instruction is:
- USING address,register1[,register2[,...]]
Register1 can be any of the general purpose registers 1 through 15. It tells the assembler that this register has been loaded with the address specified as the first parameter. Because many instructions - including branch instructions - treat register 0 as a non-action or containing the actual value 0, register 0 should not be used for this purpose. A second (or subsequent) register, indicated by the parameter register2 optionally provides a second base register, and is presumed to contain the address of the first parameter plus 4096. Each subsequent register, if specified, is presumed by the assembler tocontaino the address 4096 above the address specified in the preceding register
- PROG START 0
- BALR 12,0
- USING *,12,11
- LA 11,4095(12)
- LA 11,1(11)
In the above example, the USING pseudo-instruction tells the assembler that register 12 is established as the base register for the first 4096 bytes of this module, and that register 11 is established for the second 4096 bytes. After register 12 has been loaded with the current address through the BALR instruction, register 11 is loaded with the address 4096 bytes later in the program. Note that this uses the older LA instruction, which cannot add more than 4095 to the value contained in a register, so two LA instructions must be used. While this combination of instructions will work on all models of IBM hardware as well as competitor's equipment, later versions of IBM hardware such as the z/Series provide more efficient instructions for this purpose.
- Operating systems often use register 0 and 1 in Supervisor Calls and expect values or address of a list of values to be provided using one or both of these registers; they are also often used (sometimes along with register 15) to return result values from Supervisor Calls. For this reason, register 1 should not be used as a base register in an executable code section, but is acceptable to reference a DSECT mapping labels to the displacement from Register 1.
- Some operating systems and certain instructions may provide or use Register 2 and/or Register 15, so care should be taken if Register 2 or 15 is used as the base register in an assembly language module that issues supervisor calls or macros that issue supervisor calls.
- The Linux operating system on the 390/zSystem hardware uses registers 1 through 6 for arguments, so these registers should not be considered to remain the same or be usable after a supervisor call on S/390 Linux.
- Register 13 is often used as a pointer to an 18-word register save area (for programs running in 24 or 32 bit mode), so it should only be used for this purpose. If the program is not calling any subroutines and saves the value of register 13 on entry, and restores it on exit, register 13 may be used for any purpose. However, if register 13 is being used for some other purpose where it is not pointing to a save area, this should be documented in the program so that anyone doing maintenance on the program in the future is not confused by this practice. Note, register 13 can be used for other purposes such as to point to a rewritable area (such as for reentrant programs that dynamically acquire memory) or for anything else, as long as the first 18 words it points to are available as a register save area.
- Register 14 is often used as the return address for the program to exit back to the caller (or the operating system if the program is not a subroutine). If the program saves register 14 on entry, and restores it on exit, register 14 may be used for any purpose.
- Register 15 is typically provided as the entry point of the program, and thus is acceptable as the USING register; only if the program must itself call a subroutine, then it must establish a different register as its base register. However, some operating systems also use register 15 in addition to registers 0 and 1 to return values, so it may be best not to use register 15 as a base register if the routine issues supervisor calls or macros that issue supervisor calls.
Address can be * for the current program counter, or it can be a label in the current module, or a label plus a value. This allows the assembler to know which base register to use for references to addresses in the current module. It may also be used when referencing a DSECT to assign to labels used in the DSECT a base/displacement address.
A main program (i.e. not a subroutine which has a base register loaded by the caller) would use the BALR or BASR instruction to load the contents of a base register, then issue a USING pseudo-instruction to inform the assembler that the particular register was available as a base register.
|360 Assembler Pseudo Instructions|
|Address Related||ADATA • CNOP • DROP • EQU • LOCTR • LTORG • ORG • USING|
|Code Related||ALIAS • AMODE • CATTR • COM • CSECT • CXD • DSECT • DXD • END • ENTRY • EXTRN • OPSYN • RMODE • RSECT • START • WXTRN • XATTR|
|Data Related||CCW • CCW0 • CCW1 • DC • DS|
|Conditional Assembly and Macro related||ACTR • AGO • AIF • AINSERT • ANOP • AREAD • COPY • GBLA / GBLB / GBLC • LCLA / LCLB / LCLC • MACRO • MEND • MEXIT • MNOTE • SETA / SETB / SETC|
|Listing, output and source related||Comments • *PROCESS • ACONTROL • EJECT • END • EXITCTL •ICTL • ISEQ • POP • PRINT • PUNCH • PUSH • REPRO • SPACE • TITLE|
|360 Assembly Language|
|360 Family||Introduction · Basic FAQ · 360 Family · 360 Architecture|
|360 Instruction Set||360 Instructions · Branch Instructions · Data Transfer Instructions · Control Flow Instructions · Arithmetic Instructions · Logic Instructions · Shift and Rotate Instructions · Other Instructions|
|Syntaxes and Assemblers||360 Assemblers· Pseudo Instructions|
|Instruction Extensions||Floating Point · High-Level Languages|