Assembler instructions are coded using the structure described below. Comments can be omitted.
[Operands] [Comments]
add r0, r1, r2 // r0 = r1 + r2 mul r3, c0, v0 // r3 = c0 + v0
When outputting calculation results to registers that have multiple components, you can specify which components to output.
Only the values for the specified components will be updated. If nothing has been specified, all components will be updated.
Specify components this order: x, y, z, w. (You cannot specify them in other orders, such as "wzyx".)
Examples:
add r0.x, r1, r2 // The x component is updated. The yzw components are not updated. mov r0.yz, r1 // The yz components are updated. The xw components are not updated. dp3 r0, r1, r2 // All components (xyzw) are updated.
If you are using a register that has multiple components as an input operand, you can rearrange (swizzle) the components used for computations.
If this is not specified, the components will be used in this order: x, y, z, w.
If fewer than four components are specified, the component specified last will be repeated.
Example:
add r0, r1.xzyy, r2 // r0.x = r1.x + r2.x
// r0.y = r1.z + r2.y
// r0.z = r1.y + r2.z
// r0.w = r1.y + r2.w
mov r0, r1.ywz // r0.x = r1.y
// r0.y = r1.w
// r0.z = r1.z
// r0.w = r1.z ; The last specified component (z) is repeated
add r0, r1.zw, r2.xy // r0.x = r1.z + r2.x
// r0.y = r1.w + r2.y
// r0.z = r1.w + r2.y
// r0.w = r1.w + r2.y
mov r0.x, r1.xy // r0.x = r1.x ; (r1.xyyy) mov r0.y, r1.xy // r0.y = r1.y ; (r1.xyyy) mov r0.z, r1.xy // r0.z = r1.y ; (r1.xyyy) mov r0.w, r1.xy // r0.w = r1.y ; (r1.xyyy) add r0.zw, r1.yx, r2.wz // r0.z = r1.x + r2.z;(r1.yxxx + r2.wzzz) // r0.w = r1.x + r2.z;(r1.yxxx + r2.wzzz)In the above examples, the red-colored input components are used for the output components.
You can attach the negative sign ( - ) to input operands.
Example:
add r0, r1, -r2 // r0 = r1 – r2 mul r0, –r1, r2 // r0 = (–r1) * r2
You can offset input operand register numbers by enclosing them in square brackets ("[ ]").
A sum of multiple integers can be enclosed in brackets. If the offset integer sum exceeds the number of registers, an error will occur when assembling.
You can offset floating-point constant registers only, or address registers as well as loop-counter registers.
For address registers, you need to specify either the x component or the y component.
Behavior is undefined if the total combined index offset of the address registers and loop counter registers is outside the range of [0, 95].
Example:
c2 // Index is 2 v[5 + 2] // Index is 5 + 2 r8[1 + 2 + 4] // Index is 8 + 1 + 2 + 4 c[3 + a0.x] // Index is 3 + a0.x c4[11 + aL] // Index is 4 + 11 + aL
Labels can specify jumps to call instructions and jpb instructions.
Labels take the form of names comprising a combination of ASCII alphanumeric characters and underscores ("_") followed by a colon.
You cannot use reserved words (like the register names r0, c0) or names that represent numbers (either decimal or hexadecimal, such as 123 or 0xf).
Lines that contain code labels cannot contain anything other than comments.
Example:
function0:
mov r0, r1
...
ret
main:
...
call function0
main Label
The vertex shader invariably starts from a main label.
Shaders that do not have the main label are referenced as subroutines.
When the assembler file for the vertex shader is being assembled and linked, you must link a main object that contains at least one main label. An endmain label must also be set in this main object.
Set the endmain label immediately after the final executed instruction. (The final executed instruction is the instruction that gets written to the output register last.)
You cannot use the same label name more than once in an object file. Also, if you link multiple object files, you cannot use the same label name in multiple object files for subroutines.
Main objects do not reference each other, so it is all right to use the same label name in multiple main objects.
The following strings are defined as reserved words by the assembler. Do not use these reserved words for such things as label names and symbol names.
・Register names
v0-v15, r0-r15, c0-c95, a0, b0-b15, i0-i3, aL, o0-o15
def, defb, defi, add, dp3, dp4, dph, dst, exp, flr, litp, log, mad, max, min, mov, mova, mul, nop, rcp, rsq, sge, slt, sub, abs, crs, frc, lrp, m3x2, m3x3, m3x4, m4x3, m4x4, nrm, pow, sgn, sincos, call, callc, callb, jpb, jpc, ret, ifb, ifc, else, endif, loop, endloop, breakc, cmp, end
include, define, undef, ifdef, ifndef, if, defined, else, elif, endif, error, pragma, bind_symbol, output_map
CONFIDENTIAL