NonStop S-Series Server Description Manual (G06.24+)

TNS Execution Modes
HP NonStop S-Series Server Description Manual520331-003
6-6
The Environment Register
The Environment Register
The 16-bit ENV (Environment) register shows the state of the currently executing
procedure. That is, the register indicates the code space in which the procedure is
currently executing, the data segment that it is using, whether or not privileged mode is
in use, whether or not arithmetic traps are enabled, and specific results of the most
recent instruction (overflow, carry, and condition code). The format of the ENV register
is shown in Figure 6-3. The register pointer (RP) is separately described in the
succeeding two topics.
The individual fields of the ENV register are frequently referred to and updated by the
operating system and millicode. Most fields are saved (along with the contents of the
P and L registers) as part of the executing state of the procedure when it calls some
other procedure. (The condition code and register stack pointer fields do not need to
be saved, and instead bits 11 through 15 are used to save the space identification of
the calling procedure.) Most of the ENV register is restored to its previous state when
the called procedure finishes. (All fields in ENV are saved and restored for an
interrupt.)
The library space bit, or LS bit, (ENV.<4>) works with the CS bit (ENV.<7>) to define
the current code space. When this bit is equal to 1, it indicates that the current
procedure is located in one of the library code spaces (user library or system library)
rather than in one of the standard code spaces (user code or system code). The CS
bit determines which of the two library spaces is indicated. In the case of “system
indication by CS, the current procedure is in the system library space; in the case of
“user” indication by CS, the procedure is in the user library space.
The privileged mode bit, or PRIV bit, (ENV.<5>), when equal to 1, indicates that the
processor is currently executing in privileged mode and is permitted to perform
privileged operations. Normally, only the operating system executes in privileged
mode. Nonprivileged programs can perform privileged operations only indirectly, by
calling procedures designated as callable. When a nonprivileged procedure calls a
callable procedure, its nonprivileged state is restored on return.
The data space bit, or DS bit, (ENV.<6>) defines the current data segment. This
specifies which data area is to be accessed when a data reference is made to relative
segment 0. DS, when equal to 0, specifies the user data segment; when equal to 1, it
specifies the system data segment. DS equals 1 only in the interrupt environment.
The code space bit, or CS bit, (ENV.<7>), together with the LS bit (ENV.<4>), defines
the current code space. CS, when equal to 0, specifies the user code space (or the
user library space if LS is equal to 1); CS equal to 1 specifies the system code space
(or the system library space if LS is equal to 1).
The trap enable bit, or T bit, (ENV.<8>) controls the overflow trap, enabling it when T
= 1 or disabling it when T = 0. The T bit can be set to either state by the SETE
instruction. When the trap is enabled and an overflow occurs (see “Overflow Bit” later
in this topic), control is transferred to the arithmetic overflow interrupt handler. When
the trap is disabled, the program may choose to ignore the overflow bit or test it for
specific handling.