1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../css/manpage.css" type="text/css" /> 7 <title>Syntax</title> 8 </head> 9 <body> 10 <h1>Syntax</h1> 11 <div class="section"> 12 <p> 13 </p> 14 </div> 15 16 <h2><a name="grammar">Assembler Instruction Coding</a></h2> 17 <div class="section"> 18 <p> 19 Assembler instructions are coded using the structure described below. Comments can be omitted.<br> 20<pre class="definition"> 21<Operation> [Operands] [Comments] 22</pre> 23 <br> Example:<br> 24<pre class="definition"> 25add r0, r1, r2 // r0 = r1 + r2 26mul r3, c0, v0 // r3 = c0 + v0 27</pre> 28 <br> Assembler instructions are coded using ASCII characters according to the rules described below.<br> 29 <dl> 30 <dt><b>Operation</b></dt> 31 <dd>For operation, specify an assembler instruction to execute. You cannot code multiple operations on the same line.</dd> 32 <br><br> 33 <dt><b>Operands</b></dt> 34 <dd>Operand name [operand]<br>Specifies the operand names, such as registers and values, used in the operation. Enter at least one space or tab after the operation and before the operand name. If you are coding multiple operands, separate them with commas. You can also enter one or more spaces or tabs between operands.</dd> 35 <br><br> 36 <dt><b>Comment</b></dt> 37 <dd>Anything coded after a set of double slashes (" // ") is treated as comments. Any coding enclosed between "/*" and "*/" is also treated as comments.</dd> 38 <br><br> 39 </dl> 40 </p> 41 </div> 42 43 <h2><a name="masking">Masking Output Components</a></h2> 44 <div class="section"> 45 <p> 46 When outputting calculation results to registers that have multiple components, you can specify which components to output.<br> Only the values for the specified components will be updated. If nothing has been specified, all components will be updated.<br> Specify components this order: x, y, z, w. (You cannot specify them in other orders, such as "wzyx".)<br> <br>Examples:<br> 47<pre class="definition"> 48add r0.x, r1, r2 // The x component is updated. The yzw components are not updated. 49mov r0.yz, r1 // The yz components are updated. The xw components are not updated. 50dp3 r0, r1, r2 // All components (xyzw) are updated. 51</pre> 52 </p> 53 </div> 54 55 <h2><a name="swizzling">Swizzling (Rearranging Input Components)</a></h2> 56 <div class="section"> 57 <p> 58 If you are using a register that has multiple components as an input operand, you can rearrange (swizzle) the components used for computations.<br> If this is not specified, the components will be used in this order: x, y, z, w. <br> <br> If fewer than four components are specified, the component specified last will be repeated.<br> <br> Example:<br> 59<pre class="definition"> 60add r0, r1.xzyy, r2 // r0.x = r1.x + r2.x 61 // r0.y = r1.z + r2.y 62 // r0.z = r1.y + r2.z 63 // r0.w = r1.y + r2.w 64mov r0, r1.ywz // r0.x = r1.y 65 // r0.y = r1.w 66 // r0.z = r1.z 67 // r0.w = r1.z ; The last specified component (z) is repeated 68add r0, r1.zw, r2.xy // r0.x = r1.z + r2.x 69 // r0.y = r1.w + r2.y 70 // r0.z = r1.w + r2.y 71 // r0.w = r1.w + r2.y 72</pre> 73 <br> Note that if input components are swizzled, the parsing of masking for the output components will differ if fewer than four components have been specified.<br> The x, y, z, and w components specified for masking of output components will be applied respectively to the 1st, 2nd, 3rd, and 4th input components after swizzling has been performed.<br> <br> Example:<br> 74<pre class="definition"> 75mov r0.x, r1.xy // r0.x = r1.x ; (r1.<span style="color: red;">x</span>yyy) 76mov r0.y, r1.xy // r0.y = r1.y ; (r1.x<span style="color: red;">y</span>yy) 77mov r0.z, r1.xy // r0.z = r1.y ; (r1.xy<span style="color: red;">y</span>y) 78mov r0.w, r1.xy // r0.w = r1.y ; (r1.xyy<span style="color: red;">y</span>) 79add r0.zw, r1.yx, r2.wz // r0.z = r1.x + r2.z;(r1.yx<span style="color: red;">x</span>x + r2.wz<span style="color: red;">z</span>z) 80 // r0.w = r1.x + r2.z;(r1.yxx<span style="color: red;">x</span> + r2.wzz<span style="color: red;">z</span>) 81</pre> 82 In the above examples, the red-colored input components are used for the output components. <br> <br> 83 </p> 84 </div> 85 86 <h2><a name="minus_sign">Adding the Negative Sign ( - ) to Input Components</a></h2> 87 <div class="section"> 88 <p> 89 You can attach the negative sign ( - ) to input operands.<br> <br> Example:<br> 90<pre class="definition"> 91add r0, r1, -r2 // r0 = r1 – r2 92mul r0, –r1, r2 // r0 = (–r1) * r2 93</pre> 94 </p> 95 </div> 96 97 <h2><a name="input_offset">Offsetting the Input Operand Register Index</a></h2> 98 <div class="section"> 99 <p> 100 You can offset input operand register numbers by enclosing them in square brackets ("[ ]").<br> 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.<br> <br> You can offset floating-point constant registers only, or address registers as well as loop-counter registers.<br> For address registers, you need to specify either the x component or the y component.<br> Behavior is undefined if the total combined index offset of the address registers and loop counter registers is outside the range of [0, 95].<br> <br> Example:<br> 101<pre class="definition"> 102c2 // Index is 2 103v[5 + 2] // Index is 5 + 2 104r8[1 + 2 + 4] // Index is 8 + 1 + 2 + 4 105c[3 + a0.x] // Index is 3 + a0.x 106c4[11 + aL] // Index is 4 + 11 + aL 107</pre> 108 </p> 109 </div> 110 111 <h2><a name="label">Labels</a></h2> 112 <div class="section"> 113 <p> 114Labels can specify jumps to <CODE>call</CODE> instructions and <CODE>jpb</CODE> instructions.<br><br> Labels take the form of names comprising a combination of ASCII alphanumeric characters and underscores ("_") followed by a colon.<br> You cannot use reserved words (like the register names r0, c0) or names that represent numbers (either decimal or hexadecimal, such as <CODE>123</CODE> or <CODE>0xf</CODE>).<br> Lines that contain code labels cannot contain anything other than comments.<br> <br> Example:<br> 115<pre class="definition"> 116function0: 117 mov r0, r1 118 ... 119 ret 120 121main: 122 ... 123 call function0 124</pre> 125 126 <h3>The <CODE>main</CODE> Label</h3> 127 <div class="section"> 128 <p> 129 The vertex shader invariably starts from a <CODE>main</CODE> label.<br> Shaders that do not have the <CODE>main</CODE> label are referenced as subroutines.<br> When the assembler file for the vertex shader is being assembled and linked, you must link a main object that contains at least one <CODE>main</CODE> label. An <CODE>endmain</CODE> label must also be set in this main object.<br> <br>Set the <CODE>endmain</CODE> label immediately after the final executed instruction. (The final executed instruction is the instruction that gets written to the output register last.)<br> 130 </p> 131 </div> 132 <h3>Label Name Conflicts</h3> 133 <div class="section"> 134 <p> 135 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.<br> Main objects do not reference each other, so it is all right to use the same label name in multiple main objects.<br> 136 </p> 137 </div> 138 </p> 139 </div> 140 141 <h2><a name="reserved">Reserved Words</a></h2> 142 <div class="section"> 143 <p> 144 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.<br> <br> <br> <b>・Register names</b><br> 145<pre class="definition"> 146v0-v15, r0-r15, c0-c95, a0, b0-b15, i0-i3, aL, o0-o15 147</pre> 148 <br> <b>・Assembler instructions</b><br> 149<pre class="definition"> 150def, defb, defi, 151add, dp3, dp4, dph, dst, exp, flr, litp, log, mad, max, min, mov, mova, mul, nop, rcp, rsq, sge, slt, 152sub, abs, crs, frc, lrp, m3x2, m3x3, m3x4, m4x3, m4x4, nrm, pow, sgn, sincos, 153call, callc, callb, jpb, jpc, ret, ifb, ifc, else, endif, loop, endloop, breakc, cmp, end 154</pre> 155 <br> <b>・Pre-processor</b><br> 156<pre class="definition"> 157include, define, undef, ifdef, ifndef, if, defined, else, elif, endif, error, pragma, bind_symbol, output_map 158</pre> 159 </p> 160 </div> 161 162 163 <h2>Revision History</h2> 164 <div class="section"> 165 <dl class="history"> 166 <dt>2011/12/20</dt> 167 <dd>Initial version.<br /> 168 </dd> 169 </dl> 170 </div> 171 172 <hr><p>CONFIDENTIAL</p></body> 173</html> 174