16.2. Syntax

The D30V syntax is based on the syntax in Mitsubishi's D30V architecture manual. The differences are detailed below.

16.2.1. Size Modifiers

The D30V version of as uses the instruction names in the D30V Architecture Manual. However, the names in the manual are sometimes ambiguous. There are instruction names that can assemble to a short or long form opcode. How does the assembler pick the correct form? as will always pick the smallest form if it can. When dealing with a symbol that is not defined yet when a line is being assembled, it will always use the long form. If you need to force the assembler to use either the short or long form of the instruction, you can append either .s (short) or .l (long) to it. For example, if you are writing an assembly program and you want to do a branch to a symbol that is defined later in your program, you can write bra.s foo. Objdump and GDB will always append .s or .l to instructions which have both short and long forms.

16.2.2. Sub-Instructions

The D30V assembler takes as input a series of instructions, either one-per-line, or in the special two-per-line format described in the next section. Some of these instructions will be short-form or sub-instructions. These sub-instructions can be packed into a single instruction. The assembler will do this automatically. It will also detect when it should not pack instructions. For example, when a label is defined, the next instruction will never be packaged with the previous one. Whenever a branch and link instruction is called, it will not be packaged with the next instruction so the return address will be valid. Nops are automatically inserted when necessary.

If you do not want the assembler automatically making these decisions, you can control the packaging and execution type (parallel or sequential) with the special execution symbols described in the next section.

16.2.3. Special Characters

; and # are the line comment characters. Sub-instructions may be executed in order, in reverse-order, or in parallel. Instructions listed in the standard one-per-line format will be executed sequentially unless you use the -O option.

To specify the executing order, use the following symbols:


Sequential with instruction on the left first.


Sequential with instruction on the right first.



The D30V syntax allows either one instruction per line, one instruction per line with the execution symbol, or two instructions per line. For example

abs r2,r3 -> abs r4,r5

Execute these sequentially. The instruction on the right is in the right container and is executed second.

abs r2,r3 <- abs r4,r5

Execute these reverse-sequentially. The instruction on the right is in the right container, and is executed first.

abs r2,r3 || abs r4,r5

Execute these in parallel.

ldw r2,@(r3,r4) ||, mulx r6,r8,r9

Two-line format. Execute these in parallel.

mulx a0,r8,r9, stw r2,@(r3,r4)

Two-line format. Execute these sequentially unless -O option is used. If the -O option is used, the assembler will determine if the instructions could be done in parallel (the above two instructions can be done in parallel), and if so, emit them as parallel instructions. The assembler will put them in the proper containers. In the above example, the assembler will put the stw instruction in left container and the mulx instruction in the right container.

stw r2,@(r3,r4) ->, mulx a0,r8,r9

Two-line format. Execute the stw instruction followed by the mulx instruction sequentially. The first instruction goes in the left container and the second instruction goes into right container. The assembler will give an error if the machine ordering constraints are violated.

stw r2,@(r3,r4) <-, mulx a0,r8,r9

Same as previous example, except that the mulx instruction is executed before the stw instruction.

Since $ has no special meaning, you may use it in symbol names.

16.2.4. Guarded Execution

as supports the full range of guarded execution directives for each instruction. Just append the directive after the instruction proper. The directives are:


Execute the instruction if flag f0 is true.


Execute the instruction if flag f0 is false.


Execute the instruction if flag f1 is true.


Execute the instruction if flag f1 is false.


Execute the instruction if both flags f0 and f1 are true.


Execute the instruction if flag f0 is true and flag f1 is false.

16.2.5. Register Names

You can use the predefined symbols r0 through r63 to refer to the D30V registers. You can also use sp as an alias for r63 and link as an alias for r62. The accumulators are a0 and a1.

The D30V also has predefined symbols for these control registers and status bits:


Processor Status Word


Backup Processor Status Word


Program Counter


Backup Program Counter


Repeat Count


Repeat Start address


Repeat End address


Modulo Start address


Modulo End address


Instruction Break Address


Flag 0


Flag 1


Flag 2


Flag 3


Flag 4


Flag 5


Flag 6


Flag 7


Same as flag 4 (saturation flag)


Same as flag 5 (overflow flag)


Same as flag 6 (sticky overflow flag)


Same as flag 7 (carry/borrow flag)


Same as flag 7 (carry/borrow flag)

16.2.6. Addressing Modes

as understands the following addressing modes for the D30V. Rn in the following refers to any of the numbered registers, but not the control registers.


Register direct


Register indirect


Register indirect with post-increment


Register indirect with post-decrement


Register indirect with pre-decrement

@(disp, Rn)

Register indirect with displacement


PC relative address (for branch or rep).


Immediate data (the # is optional and ignored)