![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
VAX MACRO and Instruction Set Reference Manual
The assembler automatically defines two program sections: the absolute program section and the unnamed (or blank) program section. Any symbol definitions that appear before any instruction, data, or .PSECT directive are placed in the absolute program section. Any instructions or data that appear before the first named program section is defined are placed in the unnamed program section. Any .PSECT directive that does not include a program section name specifies the unnamed program section. A maximum of 254 user-defined, named program sections can be defined. When the assembler encounters a .PSECT directive that specifies a new program section name, it creates a new program section and stores the name, attributes, and alignment of the program section. The assembler includes all data and instructions that follow the .PSECT directive in that program section until it encounters another .PSECT directive. The assembler starts all program sections at a location counter of 0, which is relocatable. If the assembler encounters a .PSECT directive that specifies the name of a previously defined program section, it stores the new data or instructions after the last entry in the previously defined program section. The location counter is set to the value of the location counter at the end of the previously defined program section. You need not list the attributes when continuing a program section but any attributes that are listed must be the same as those previously in effect for the program section. A continuation of a program section cannot contain attributes conflicting with those specified in the original .PSECT directive. The attributes listed in the .PSECT directive only describe the contents of the program section. The assembler does not check to ensure that the contents of the program section actually include the attributes listed. However, the assembler and the linker do check that all program sections with the same name have exactly the same attributes. The assembler and linker display an error message if the program section attributes are not consistent. Program section names are independent of local symbol, global symbol, and macro names. You can use the same symbolic name for a program section and for a local symbol, global symbol, or macro name.
Example
.QUAD
Quadword storage directive Format.QUAD literal Parameters
Description.QUAD generates 64 bits (8 bytes) of binary data. .QUAD is like .OCTA and different from other data storage directives (.BYTE, .WORD, and .LONG) in that it does not evaluate expressions and that it accepts only one value. It does not accept a list. Example
.REFn
Operand generation directives Format.REF1 operand Parameter
DescriptionVAX MACRO has the following five operand generation directives that you can use in macros to define new opcodes: Example
.REPEAT
Repeat block directive Format.REPEAT expression Parameters
Description.REPEAT repeats a block of code a specified number of times, in line with other source code. The .ENDR directive specifies the end of the range. The alternate form of .REPEAT is .REPT.
Example
.RESTORE_PSECT
Restore previous program section context directive Format.RESTORE_PSECT Description.RESTORE_PSECT retrieves the program section from the top of the program section context stack, an internal stack in the assembler. If the stack is empty when .RESTORE_PSECT is issued, the assembler displays an error message. When .RESTORE_PSECT retrieves a program section, it restores the current location counter to the value it had when the program section was saved. The local label block is also restored if it was saved when the program section was saved. See the description of .SAVE_PSECT for more information.
Example
.SAVE_PSECT
Save current program section context directive Format.SAVE_PSECT [LOCAL_BLOCK] Parameter
Description.SAVE_PSECT stores the current program section context on the top of the program section context stack, an internal assembler stack. It leaves the current program section context in effect. The program section context stack can hold 31 entries. Each entry includes the value of the current location counter and the maximum value assigned to the location counter in the current program section. If the stack is full when .SAVE_PSECT is encountered, an error occurs. The alternate form of .SAVE_PSECT is .SAVE. Example
.SHOW
|
Long Form | Short Form | Default | Function |
---|---|---|---|
BINARY | MEB | NOSHOW | Lists macro and repeat block expansions that generate binary code. BINARY is a subset of EXPANSIONS. |
CALLS | MC | SHOW | Lists macro calls and repeat block specifiers. |
CONDITIONALS | CND | SHOW | Lists unsatisfied conditional code associated with the conditional assembly directives. |
DEFINITIONS | MD | SHOW | Lists macro and repeat range definitions that appear in an input source file. |
EXPANSIONS | ME | NOSHOW | Lists macro and repeat range expansions. |
.SHOW and .NOSHOW specify listing control options in the source text of a program. You can use .SHOW and .NOSHOW with or without an argument list.When you use them with an argument list, .SHOW includes and .NOSHOW excludes the lines specified in Table 6-8. .SHOW and .NOSHOW control the listing of the source lines that are in conditional assembly blocks (see the description of .IF), macros, and repeat blocks.
When you use them without arguments, these directives alter the listing level count. The listing level count is initialized to 0. Each time .SHOW appears in a program, the listing level count is incremented; each time .NOSHOW appears in a program, the listing level count is decremented.
When the listing level count is negative, the listing is suppressed (unless the line contains an error). Conversely, when the listing level count is positive, the listing is generated. When the count is 0, the line is either listed or suppressed, depending on the value of the listing control symbolic arguments.
.MACRO XX . . . .SHOW ; List next line X=. .NOSHOW ; Do not list remainder . ; of macro expansion . . .ENDM .NOSHOW EXPANSIONS ; Do not list macro ; expansions XX X=. |
Signed byte data directive
.SIGNED_BYTE expression-list
expression-list
An expression or list of expressions separated by commas (,). You have the option of following each expression with a repetition factor delimited by square brackets ([]).An expression followed by a repetition factor has the format:
expression1[expression2]
expression1
An expression that specifies the value to be stored. The value must be in the range -128 to +127.[expression2]
An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets are required.
.SIGNED_BYTE is equivalent to .BYTE, except that VAX MACRO indicates that the data is signed in the object module. The linker uses this information to test for overflow conditions.
Specifying .SIGNED_BYTE allows the linker to detect overflow conditions when the value of the expression is in the range of 128 to 255. Values in this range can be stored as unsigned data but cannot be stored as signed data in a byte.
.SIGNED_BYTE LABEL1-LABEL2 ; Data must fit .SIGNED_BYTE ALPHA[20] ; in byte |
Signed word storage directive
.SIGNED_WORD expression-list
expression-list
An expression or list of expressions separated by commas (,). You have the option of following each expression with a repetition factor delimited by square brackets ([]).An expression followed by a repetition factor has the format:
expression1[expression2]
expression1
An expression that specifies the value to be stored. The value must be in the range -32,768 to +32,767.[expression2]
An expression that specifies the number of times the value will be repeated. The expression must not contain any undefined symbols and must be an absolute expression (see Section 3.5). The square brackets ([]) are required.
.SIGNED_WORD is equivalent to .WORD except that the assembler indicates that the data is signed in the object module. The linker uses this information to test for overflow conditions. .SIGNED_WORD is useful after the case instruction to ensure that the displacement fits in a word.
Specifying .SIGNED_WORD allows the linker to detect overflow conditions when the value of the expression is in the range of 32,768 to 65,535. Values in this range can be stored as unsigned data but cannot be stored as signed data in a word.
.MACRO CASE,SRC,DISPLIST,TYPE=W,LIMIT=#0,NMODE=S^#,?BASE,?MAX ; MACRO to use CASE instruction, ; SRC is selector, DISPLIST ; is list of displacements, TYPE ; is B (byte) W (word) L (long), ; LIMIT is base value of selector CASE'TYPE SRC,LIMIT,NMODE'<<MAX-BASE>/2>-1 ; Case instruction BASE: ; Local label specifying base .IRP EP,<DISPLIST> ; to set up offset list .SIGNED_WORD EP-BASE ; Offset list .ENDR ; MAX: ; Local label used to count .ENDM CASE ; args CASE IVAR <ERR_PROC,SORT,REV_SORT> ; If IVAR=0, error CASEW IVAR,#0,S^#<<30001$-30000$>/2>-1 30000$: ; Local label specifying base .SIGNED_WORD ERR_PROC-30000$ ; Offset list .SIGNED_WORD SORT-30000$ ; Offset list .SIGNED_WORD REV_SORT-30000$ ; Offset list 30001$: ; Local label used to count args ; =1, forward sort; =2, backward ; sort CASE TEST <TEST1,TEST2,TEST3>,L,#1 CASEL TEST,#1,S^#<<30003$-30002$>/2>-1 30002$: ; Local label specifying base .SIGNED_WORD TEST1-30002$ ; Offset list .SIGNED_WORD TEST2-30002$ ; Offset list .SIGNED_WORD TEST3-30002$ ; Offset list 30003$: ; Local label used to count args ; Value of TEST can be 1, 2, or 3 |
In this example, the CASE macro uses .SIGNED_WORD to create a CASEB, CASEW, or CASEL instruction.
Previous | Next | Contents | Index |