From VSI OpenVMS Wiki
Jump to: navigation, search

$ADJSTK, or Adjust Outer Mode Stack Pointer, is a system service that modifies the stack pointer for a less privileged access mode. The operating system uses this service to modify a stack pointer for a less privileged access mode after placing arguments on the stack.


SYS$ADJSTK [acmode] ,[adjust] ,newadr

C Prototype:

int sys$adjstk (unsigned int acmode, short int adjust, void *(*(newadr)));



OpenVMS usage: access_mode
Type: longword (unsigned)
Access: read only
Mechanism: by value

Access mode for which the stack pointer is to be adjusted. The acmode argument is this longword value. If not specified, the default value 0 (kernel access mode) is used.


OpenVMS usage: word_signed
Type: word (signed)
Access: read only
Mechanism: by value

Signed adjustment value used to modify the value specified by the newadr argument. The adjust argument is a signed longword, which is the adjustment value. Only the low-order word of this argument is used. The value specified by the low-order word is added to or subtracted from (depending on the sign) the value specified by the newadr argument. The result is loaded into the stack pointer for the specified access mode. If the adjust argument is not specified or is specified as 0, the stack pointer is loaded with the value specified by the newadr argument.


OpenVMS usage: address
Type: longword (unsigned)
Access: modify
Mechanism: by reference

Value that adjust is to adjust. The newadr argument is the address of this longword value.

The value specified by this argument is both read and written by $ADJSTK. The $ADJSTK service reads the value specified and adjusts it by the value of the adjust argument (if specified). After this adjustment is made, $ADJSTK writes the adjusted value back into the longword specified by newadr and then loads the stack pointer with the adjusted value. If the value specified by newadr is 0, the current value of the stack pointer is adjusted by the value specified by adjust. This new value is then written back into newadr, and the stack pointer is modified.

Combinations of zero and nonzero values for the adjust and newadr arguments provide the following results:

adjust value newadr value stack pointer
0 0 Not changed
0 An address Loaded with the address specified
A value 0 Adjusted by the specified value
A value An address Loaded with the specified address, adjusted by the specified value

In all cases, the updated stack pointer value is written into the value specified by the newadr argument.

Privileges Required

No privileges.

Condition Values Returned

Value Description
SS$_NORMAL The service completed successfully.
SS$_ACCVIO The value specified by newadr or a portion of the new stack segment cannot be written by the caller.
SS$_NOPRIV The specified access mode is equal to or more privileged than the calling access mode.

See also