VMS Help  —  MACRO  /ALPHA  Supplied Library Macros, $OPDEF
    Used to define opcodes.

    Format

      $OPDEF  MNEMONIC, FORMAT, ENCODING [,DEFAULTS]

1  –  Parameters

 MNEMONIC

    MNEMONIC is the mnemonic name by which the instruction is called.
    You may optionally specify a qualifier list separated from the
    name by a slash (/).  A qualifier list is a sequence of one or
    more letters or digits with no intervening spaces or separators.

 FORMAT

    FORMAT is one of the following arguments:

    Format                      Description

    MEMORY                      Standard memory format instructions.
    MEMORY_FUNCTION             Memory format instructions with a
                                function code.
    JUMP                        Memory format instructions formatted
                                like jump instructions.
    BRANCH                      Standard branch format instructions.
    OPERATE                     Standard operate instructions.
    FLOATING_OPERATE            Standard floating-point operate
                                instructions.
    PAL                         Standard PALcode instructions.
    <CUSTOM=operand_type_list>  Custom format.

    With the CUSTOM format, you may optionally specify a list of the
    types of operands the instruction is to accept. If you specify
    a list of operand types, you must enclose the entire FORMAT
    argument within angle brackets, and you must specify the operand
    types in the order they are to be used with the instruction.
    $OPDEF supports the following operand types:

    IREGISTER      Integer register, such as R5 or SP.
    FREGISTER      Floating-point register, such as F7.
    LITERAL        Integer literal, such as #123 or 32767.
    LIT_IREG       Integer literal, such as #123 or 32767, or integer
                   register, such as R5 or SP.
    INDIRECT       Indirect integer register notation such as (R7).
    DISPLACEMENT   Indirect integer register notation with an integer
                   literal displacement, such as FOO(R12).
    BRANCH_OFFSET  Label or address expression, such as L1.

    For example:

    FORMAT=<CUSTOM=IREGISTER,DISPLACEMENT>

    The following example shows the definition of the ADDQ
    instruction, which takes either an integer register or literal
    as its second argument:

        $OPDEF ADDQ,                                      -
            FORMAT=<CUSTOM=IREGISTER,LIT_IREG,IREGISTER>, -
            ENCODING=<26:31=^x10,                         -
                21:25=%OP1,                               -
                12:20=%OP2,                               -
                5:11=^x20,                                -
                0:4=%OP3>

    For a detailed description of instruction formats, see the Alpha
    Architecture Reference Manual.

 ENCODING

    ENCODING is the numeric encoding for the instruction opcode.
    The default radix is decimal, as is the case for all assembler
    constants. Prefix the value with ^X for hexadecimal. Certain
    instruction formats allow multipart encoding:

    Format             Encoding Description

    MEMORY_FUNCTION    Specify the base opcode, followed by a dot,
                       followed by the function code. For example:

                       ENCODING=^X10.F000
    JUMP               Specify the base opcode, optionally followed
                       by a dot, and the hardware-hint bits
                       optionally followed by a dot and the software-
                       hint bits. For example:

                       ENCODING=^X1A.2.1
    OPERATE            Specify the base opcode, followed by a dot,
                       followed by the function code. For example:

                       ENCODING=^X12.3C
    FLOATING_OPERATE   Specify the base opcode, followed by a dot and
                       the function code. For example:

                       ENCODING=^X17.02B
    PAL                Specify the base opcode, optionally followed
                       by a dot and the function code. Omit the
                       function code for a generic PAL instruction
                       that accepts an integer-expression argument.
                       For example:

                       ENCODING=^X0.0080
                       ENCODING=^X19
    CUSTOM             Specify a comma-separated list of bit ranges
                       and values to place in those bit ranges. For
                       example:

                       ENCODING = < 26:31=^X14, 21:25=%OP1, -
                                    16:20=%OP2.REG, 0:15=%OP2.DISP >

    For CUSTOM format instructions, specify the ENCODING argument as
    a comma-separated list of bit ranges and values to place in those
    bit ranges. Enclose the list within angle brackets.

    Specify a bit range as start:end where start and end are integer
    constant expressions. For a 1-bit bit range, start and end are
    equal. Bit positions range from 0 to 31. Place an equal sign (=)
    after the bit-range specifier followed by the value you wish to
    put in the bit range. You can place either a constant integer
    expression or an operand into the bit range. Start and end
    expressions and integer constant expressions must not reference
    any external symbols or symbols not yet defined in the assembly.
    $OPDEF evaluates these expressions at the time that it defines
    the instruction as opposed to when the defined instruction is
    referenced.

    Operand names are of the form %OPn, where n is the ordinal number
    of the operand as specified from left to right with the FORMAT
    argument.

    For the IREGISTER, FREGISTER, and INDIRECT operands, $OPDEF
    places the 5-bit register number into the bit positions you
    specify.

    For LITERAL operands, $OPDEF places the literal value of the
    operand into the bit positions you specify. Operand literal
    values can be up to 32 bits long. The most significant bits
    are truncated if the size of the operand literal value exceeds
    the bit range you specify. Forward and external references are
    allowed.

    For LIT_IREG operands, $OPDEF places either a literal value or
    a 5-bit register number into the bit positions you specify. If a
    literal, the low bit is 1, and the literal value is placed in the
    upper bits. If an integer register, the low four bits are 0, and
    the high five bits contain the register number.

    For DISPLACEMENT operands, $OPDEF defines two parts: a 5-bit
    register number and a displacement value that can be up to 32
    bits long. The most significant bits are truncated from the
    displacement value if the size of the displacement value exceeds
    the bit range you specify. You can reference the register number
    by placing .REG after the operand name. For example: %OP2.REG.
    Similarly, you can reference the displacement value by placing
    .DISP after the operand name. For example: %OP2.DISP. Forward
    references are allowed. Relocatable expressions are not allowed.

    For BRANCH_OFFSET operands, $OPDEF stores the signed longword
    offset between the next instruction and the specified address in
    the bit positions you specify. The address expression specified
    for a BRANCH_OFFSET operand can be a backward or forward
    reference to a location within the current psect. It cannot
    be an external address or an address in a different psect. The
    resulting offset can be up to 32 bits in size. If the size of the
    offset exceeds the bit range you specify, the most significant
    bits are truncated.

    $OPDEF fills any bit positions you leave unspecified with zeros.

 DEFAULTS

    DEFAULTS is an optional list of operand defaults of the form
    <%OPn=value, ...>, where n is the number of the operand to which
    the value is to apply as a default. Operand defaults may be
    specified in any order. If you specify a default for one or more
    operands, you need not specify a default for all operands.

    The following example specifies a default of R31 for the first
    instruction argument:

        $OPDEF RET, FORMAT=<CUSTOM=IREGISTER,INDIRECT>,   -
            ENCODING=<26:31=^x1A,                         -
                21:25=%OP1,                               -
                16:20:%OP2,                               -
                14;14=^x2,0:13=0>,                        -
            DEFAULTS=<%OP1=R31>

2  –  Description

    You can use the $OPDEF macro to define your own opcodes.

    $OPDEF defines a macro using an unqualified version of the
    mnemonic name you specify. When this macro is invoked with the
    instruction qualifiers you specify when you define it with $OPDEF
    (if any), it expands to the instruction representation you have
    defined with $OPDEF. You can specify the qualifiers in any order
    as long as the combination of qualifiers you use is the same.

    Other uses of the mnemonic name remain valid provided you do not
    use the mnemonic name as a macro name in a .MACRO directive. For
    instance, you can use the same mnemonic name in the opcode field
    with different or no qualifiers. If the qualifiers (or absence
    thereof) do not match those specified in your $OPDEF instruction
    definition, the macro defined by $OPDEF processes as though you
    had not defined an instruction by that mnemonic name. To do
    so, it expands to a single statement. This expansion statement
    is identical to the mnemonic-name macro invocation statement,
    except it is processed in a context that prevents the mnemonic-
    name macro from expanding recursively. Instead, the statement
    is processed as a normal, MACRO-64 instruction statement. In
    this case, you may notice references to the mnemonic-name macro
    expansion in a MACAUXMSG diagnostic message if the instruction
    statement contains errors.

    For instance, if you define a STQ/P instruction using $OPDEF,
    you can still use the STQ instruction without the /P qualifier.
    If you do, and your STQ instruction statement contains an error,
    the assembler generates a MACAUXMSG message indicating that the
    error occurred during the expansion of macro STQ. Aside from
    the fact that the STQ instruction is processed in the context of
    the expansion of the STQ macro, $OPDEF's definition of the STQ/P
    instruction has no effect on your use of the STQ instruction.

3  –  Example

        $OPDEF MNEMONIC=BANG, FORMAT=PAL, -
               ENCODING=^X0.0099
Close Help