Updated: 11 December 1998 |
VAX MACRO and Instruction Set Reference Manual
Previous | Contents | Index |
In literal mode, the value of the literal is stored in the addressing mode byte.
Formats
#literal
S^#literal
literal
An expression, an integer constant, or a floating-point constant. The literal must fit in the short literal form. That is, integers must be in the range 0 to 63 and floating-point constants must be one of the 64 values listed in Table 5-2 and Table 5-3. Floating-point short literals are stored with a 3-bit exponent and a 3-bit fraction. Table 5-2 and Table 5-3 also show the value of the exponent and the fraction for each literal. See Section 8.7.8 for information on the format of short literals.
Exponent | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
0 | 0.5 | 0.5625 | 0.625 | 0.6875 | 0.75 | 0.8125 | 0.875 | 0.9375 |
1 | 1.0 | 1.125 | 1.25 | 1.37 | 1.5 | 1.625 | 1.75 | 1.875 |
2 | 2.0 | 2.25 | 2.5 | 2.75 | 3.0 | 3.25 | 3.5 | 3.75 |
3 | 4.0 | 4.5 | 5.0 | 5.5 | 6.0 | 6.5 | 7.0 | 7.5 |
4 | 8.0 | 9.0 | 10.0 | 11.0 | 12.0 | 13.0 | 14.0 | 15.0 |
5 | 16.0 | 18.0 | 20.0 | 22.0 | 24.0 | 26.0 | 28.0 | 30.0 |
6 | 32.0 | 36.0 | 40.0 | 44.0 | 48.0 | 52.0 | 56.0 | 60.0 |
7 | 64.0 | 72.0 | 80.0 | 88.0 | 96.0 | 104.0 | 112.0 | 120.0 |
Exponent | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
---|---|---|---|---|---|---|---|---|
0 | 1/2 | 9/16 | 5/8 | 11/16 | 3/4 | 13/16 | 7/8 | 15/16 |
1 | 1 | 1-1/8 | 1-1/4 | 1-3/8 | 1-1/2 | 1-5/8 | 1-3/4 | 1-7/8 |
2 | 2 | 2-1/4 | 2-1/2 | 2-3/4 | 3 | 3-1/4 | 3-1/2 | 3-3/4 |
3 | 4 | 4-1/2 | 5 | 5-1/2 | 6 | 6-1/2 | 7 | 7-1/2 |
4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
5 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 |
6 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 |
7 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 |
MOVL #1,R0 ; R0 is set to 1; the 1 is stored ; in the instruction as a short ; literal. MOVB S^#CR,R1 ; The low byte of R1 is set ; to the value CR. ; CR is stored in the instruction ; as a short literal. ; If CR is not in range 0-63, ; the linker produces a ; truncation error. MOVF #0.625,R6 ; R6 is set to the floating-point ; value 0.625; it is stored ; in the floating-point short ; literal form. |
Notes
The program counter (PC) modes use the PC for a general register. Following are the five program counter modes:
In Section 8.8, Table 8-6 is a summary of PC addressing.
5.2.1 Relative Mode
In relative mode, the address specified is the address of the operand. The assembler stores the address as a displacement from the PC.
Relative mode can be used with index mode (see Section 5.3).
Format
address |
address
An expression specifying an address; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement.
Displacement Length Specifier | Meaning |
---|---|
B^ | Displacement requires 1 byte. |
W^ | Displacement requires one word (2 bytes). |
L^ | Displacement requires one longword (4 bytes). |
MOVL LABEL,R1 ; Get longword at LABEL; the ; assembler uses default ; displacement unless LABEL was ; previously defined in this ; section CMPL W^<DATA+4>,R10 ; Compare R10 with longword at ; address DATA+4; CMPL ; uses a word displacement |
In relative deferred mode, the address specified is the address of the operand address (a pointer to the operand). The assembler stores the address specified as a displacement from the PC.
Relative deferred mode can be used with index mode (see Section 5.3).
Format
@address |
address
An expression specifying an address; the expression can be preceded by one of the following displacement length specifiers, which indicate the number of bytes needed to store the displacement:
Displacement Length Specifier | Meaning |
---|---|
B^ | Displacement requires 1 byte. |
W^ | Displacement requires one word (2 bytes). |
L^ | Displacement requires one longword (4 bytes). |
CLRL @W^PNTR ; Clear longword pointed to by ; longword at PNTR; the assembler ; uses a word displacement INCB @L^COUNTS+4 ; Increment byte pointed to by ; longword at COUNTS+4; assembler ; uses a longword displacement |
In absolute mode, the address specified is the address of the operand. The address is stored as an absolute virtual address (compare relative mode, where the address is stored as a displacement from the PC).
Absolute mode can be used with index mode (see Section 5.3).
Format
@#address |
address
An expression specifying an address.
CLRL @#^X1100 ; Clear the contents of location 1100(hex) CLRB @#ACCOUNT ; Clear the contents of location ; ACCOUNT; the address is stored ; absolutely, not as a displacement CALLS #3,@#SYS$FAO ; Call the procedure SYS$FAO with ; three arguments on the stack |
In immediate mode, the literal specified is the operand.
Formats
#literal
I^#literal
literal
An expression, an integer constant, or a floating-point constant.
MOVL #1000,R0 ; R0 is set to 1000; the operand 1000 ; is stored in a longword MOVB #BAR,R1 ; The low byte of R1 is set ; to the value of BAR MOVF #0.1,R6 ; R6 is set to the floating-point ; value 0.1; it is stored ; as a 4-byte floating-point ; value (it cannot be ; represented as a short literal) ADDL2 I^#5,R0 ; The 5 is stored in a longword ; because the I^ forces the ; assembler to use immediate mode MOVG #0.2,R6 ; The value 0.2 is converted ; to its G_FLOATING representation MOVG #PI,R6 ; The value contained in PI is ; moved to R6; no conversion is ; performed |
In general mode, the address you specify is the address of the operand. The linker converts the addressing mode to either relative or absolute mode. If the address is relocatable, the linker converts general mode to relative mode. If the address is absolute, the linker converts general mode to absolute mode. You should use general mode to write position-independent code when you do not know whether the address is relocatable or absolute. A general addressing mode operand requires 5 bytes of storage.
You can use general mode with index mode (see Section 5.3).
Format
G^address |
address
An expression specifying an address.
CLRL G^LABEL_1 ; Clears the longword at LABEL_1 ; If LABEL_1 is defined as ; absolute then general mode is ; converted to absolute ; mode; if it is defined as ; relocatable, then general mode is ; converted to relative mode CALLS #5,G^SYS$SERVICE ; Calls procedure SYS$SERVICE ; with 5 arguments on stack |
Index mode is a general register mode that can be used only in combination with another mode (the base mode). The base mode can be any addressing mode except register, immediate, literal, index, or branch. The assembler first evaluates the base mode to get the base address. To get the operand address, the assembler multiplies the contents of the index register by the number of bytes of the operand data type, then adds the result to the base address.
Combining index mode with the other addressing modes produces the following addressing modes:
The process of first evaluating the base mode and then adding the index register is the same for each of these modes.
Formats
base-mode[Rx]
base-mode[AP]
base-mode[FP]
base-mode[SP]
base-mode
Any addressing mode except register, immediate, literal, index, or branch, specifying the base address.x
A number in the range 0 to 12, specifying the index register.
Table 5-4 lists the formats of index mode addressing.
; ; Register deferred index mode ; OFFS=20 ; Define OFFS MOVAB BLIST,R9 ; Get address of BLIST MOVL #OFFS,R1 ; Set up index register CLRB (R9)[R1] ; Clear byte whose address ; is the address of BLIST ; plus 20*1 CLRQ (R9)[R1] ; Clear quadword whose ; address is the address ; of BLIST plus 20*8 CLRO (R9)[R1] ; Clear octaword whose ; address is the address ; of BLIST plus 20*16 ; ; Autoincrement index mode ; CLRW (R9)+[R1] ; Clear word whose address ; is address of BLIST plus ; 20*2; R9 now contains ; address of BLIST+2 ; ; Autoincrement deferred index mode ; MOVAL POINT,R8 ; Get address of POINT MOVL #30,R2 ; Set up index register CLRW @(R8)+[R2] ; Clear word whose address ; is 30*2 plus the address ; stored in POINT; R8 now ; contains 4 plus address of ; POINT ; ; Displacement deferred index mode ; MOVAL ADDARR,R9 ; Get address of address array MOVL #100,R1 ; Set up index register TSTF @40(R9)[R1] ; Test floating-point value ; whose address is 100*4 plus ; the address stored at ; (ADDARR+40) |
Mode | Format |
---|---|
Register Deferred Index 1,2 | (Rn)[Rx] |
Autoincrement Index 1,2 | (Rn)+[Rx] |
Autoincrement Deferred
Index 1,2 |
@(Rn)+[Rx] |
Autodecrement Index 1,2 | --(Rn)[Rx] |
Displacement Index 1,2,3 | dis(Rn)[Rx] |
Displacement Deferred
Index 1,2,3 |
@dis(Rn)[Rx] |
Relative Index 2 | address[Rx] |
Relative Deferred Index 2 | @address[Rx] |
Absolute Index 2 | @#address[Rx] |
General Index 2 | G^address[Rx] |
Notes
Previous | Next | Contents | Index |
Copyright © Compaq Computer Corporation 1998. All rights reserved. Legal |
4515PRO_005.HTML
|