[ Previous | Next | Contents | Home | Search ]
AIX Version 4.3 Assembler Language Reference

.set Pseudo-op

Purpose

Sets a symbol equal to an expression in both type and value.

Syntax

.set Name,Expression

Description

The .set pseudo-op sets the Name symbol equal to the Expression value in type and in value. Using the .set pseudo-op may help to avoid errors with a frequently used expression. Equate the expression to a symbol, then refer to the symbol rather than the expression. To change the value of the expression, only change it within the .set statement. However, reassembling the program is necessary since .set assignments occur only at assembly time.

The Expression parameter is evaluated when the assembler encounters the .set pseudo-op. This evaluation is done using the rules in "Combination Handling of Expressions"; and the type and value of the evaluation result are stored internally. If evaluating the Expression, results in an invalid type, all instructions which use the symbol Name will have an error.

The stored type and value for symbol Name, not the original expression definition, are used when Name is used in other instructions.

Parameters

Name Represents a symbol that may be used before its definition in a .set statement; forward references are allowed within a module.
Expression Defines the type and the value of the symbol Name. The symbols referenced in the expression must be defined; forward references are not allowed. The symbols cannot be undefined external expressions.The symbols do not have to be within the control section where the .set pseudo-op appears.The Expression parameter can also refer to a register number, but not to the contents of the register at run time.

Examples

  1. The following example illustrates the use of the .set pseudo-op:
    .set ap,14 # Assembler assigns value 14 
                # to the symbol ap -- ap
                # is absolute.
      .
      .
    lil ap,2
     
            # Assembler substitutes value 14
            # for the symbol.
            # Note that ap is a register
            # number in context
            # as lil's operand.
  2. The following example will result in an assembly error because of an invalid type:
         .csect  a1[PR]
     L1:  l       20,30(10)
          .csect  a2[rw]
          .long   0x20
     L2:  .long   0x30
          .set    r1, L2 - L1  # r1 has type of E_REXT
                               # r1 has value of 8
          .long   r1 + 10
          .long   L2 - r1      #  Error will be reported.
                               #    L2 is E_REL
                               #    r1 is E_REXT
                               #  E_REL - E_REXT ==> Invalid type
     

Related Information

Pseudo-ops Overview.

Expressions.


[ Previous | Next | Contents | Home | Search ]