2 | | #!Markdown |
3 | | ## CLRadeonExtender Assembler syntax |
4 | | |
5 | | The CLRX assembler is compatible with GNU as syntax. In the many cases code for |
6 | | GNU as can be easily ported to CLRX assembler, ofcourse except processor instructions. |
7 | | |
8 | | ## Layout of the source |
9 | | |
10 | | The assembler accepts plain text that contains lines. Lines contains one of more |
| 2 | #!html |
| 3 | <h2>CLRadeonExtender Assembler syntax</h2> |
| 4 | <p>The CLRX assembler is compatible with GNU as syntax. In the many cases code for |
| 5 | GNU as can be easily ported to CLRX assembler, ofcourse except processor instructions.</p> |
| 6 | <h2>Layout of the source</h2> |
| 7 | <p>The assembler accepts plain text that contains lines. Lines contains one of more |
12 | | (directive) or processor's instruction. |
13 | | |
14 | | Pseudo-operations begins from `.` character. Symbol assignment is in following form: |
15 | | `symbolName=expression`. |
16 | | |
17 | | If line is too long, it can be splitted into small parts by using `\` at end of line, |
18 | | likewise as in C/C++ language. |
19 | | |
20 | | Statement can be separated in single line by semicolon `;`. Like that: |
21 | | |
22 | | ``` |
23 | | .int 1,2,3; v_nop; nop_count = nop_count+1 |
24 | | ``` |
25 | | |
26 | | Single comment begins from `#`. Multiline comment is same as in C/C++ language: |
27 | | begins from `/*` and terminates at `*/`. |
28 | | |
29 | | Names of pseudo-operations, macro names, processors instructions and other names |
| 9 | (directive) or processor's instruction.</p> |
| 10 | <p>Pseudo-operations begins from <code>.</code> character. Symbol assignment is in following form: |
| 11 | <code>symbolName=expression</code>.</p> |
| 12 | <p>If line is too long, it can be splitted into small parts by using <code>\</code> at end of line, |
| 13 | likewise as in C/C++ language. </p> |
| 14 | <p>Statement can be separated in single line by semicolon <code>;</code>. Like that:</p> |
| 15 | <p><code>.int 1,2,3; v_nop; nop_count = nop_count+1</code></p> |
| 16 | <p>Single comment begins from <code>#</code>. Multiline comment is same as in C/C++ language: |
| 17 | begins from <code>/*</code> and terminates at <code>*/</code>.</p> |
| 18 | <p>Names of pseudo-operations, macro names, processors instructions and other names |
37 | | current place of a binary code. This is `.` and is called in this manual as output counter. |
38 | | Symbol names can contains alphanumeric characters, `.` and `_`. First character |
39 | | must not be a digit. This same rules concerns a labels. |
40 | | |
41 | | Label are symbol that can not be redefined. |
42 | | Labels precedes statement and can occurred many times. Like that: |
43 | | |
44 | | ``` |
45 | | label1: init: v_add_i32 v1, v2 |
46 | | end: s_endpgm |
47 | | ``` |
48 | | |
49 | | Special kind of the label is local labels. They can be used only locally. The identifier |
| 24 | current place of a binary code. This is <code>.</code> and is called in this manual as output counter. |
| 25 | Symbol names can contains alphanumeric characters, <code>.</code> and <code>_</code>. First character |
| 26 | must not be a digit. This same rules concerns a labels.</p> |
| 27 | <p>Label are symbol that can not be redefined. |
| 28 | Labels precedes statement and can occurred many times. Like that:</p> |
| 29 | <p><code>label1: init: v_add_i32 v1, v2 |
| 30 | end: s_endpgm</code></p> |
| 31 | <p>Special kind of the label is local labels. They can be used only locally. The identifier |
53 | | adding `b` or `f` suffix. |
54 | | |
55 | | ``` |
56 | | v_add_i32 v32,3f-3b,v2 # 3b is previous `3` label, 3f is next `3` label |
57 | | ``` |
58 | | |
59 | | ### Sections |
60 | | |
61 | | Section is some part of the binary that contains some data. Type of the data depends on |
62 | | type of the section. Main program code is in the `.text` section which holds |
63 | | program's instructions. Section `.rodata` holds read-only data (mainly constant data) |
| 35 | adding <code>b</code> or <code>f</code> suffix.</p> |
| 36 | <p><code>v_add_i32 v32,3f-3b,v2 # 3b is previous `3` label, 3f is next `3` label</code></p> |
| 37 | <h3>Sections</h3> |
| 38 | <p>Section is some part of the binary that contains some data. Type of the data depends on |
| 39 | type of the section. Main program code is in the <code>.text</code> section which holds |
| 40 | program's instructions. Section <code>.rodata</code> holds read-only data (mainly constant data) |
78 | | They can be used only in `.half`, `.single`, `.float`, `.double` pseudo-operations |
79 | | or as operand of the instruction that accepts floating point literals. |
80 | | |
81 | | Literal types: |
82 | | |
83 | | * decimal literals: `100, 12, 4323` |
84 | | * hexadecimal literals: `0x354, 0x3da, 0xDAB` |
85 | | * octal literals: `0246, 077` |
86 | | * binary literals: `0b10010101, 0b11011` |
87 | | * character literals: `'a', 'b', '-', '\n', '\t', '\v', '\xab', '\123` |
88 | | * floating point literals: `10.2, .45, +1.5e, 100e-6, 0x1a2.4b5p5` |
89 | | * string literals: `"ala ma kota", "some\n" |
90 | | |
91 | | For character literals and string literals, escape can be used to put special characters |
92 | | likes newline, tab. List of the escapes: |
93 | | |
94 | | Escape | Description | Value |
| 51 | They can be used only in <code>.half</code>, <code>.single</code>, <code>.float</code>, <code>.double</code> pseudo-operations |
| 52 | or as operand of the instruction that accepts floating point literals.</p> |
| 53 | <p>Literal types:</p> |
| 54 | <ul> |
| 55 | <li>decimal literals: <code>100, 12, 4323</code></li> |
| 56 | <li>hexadecimal literals: <code>0x354, 0x3da, 0xDAB</code></li> |
| 57 | <li>octal literals: <code>0246, 077</code></li> |
| 58 | <li>binary literals: <code>0b10010101, 0b11011</code></li> |
| 59 | <li>character literals: <code>'a', 'b', '-', '\n', '\t', '\v', '\xab', '\123</code></li> |
| 60 | <li>floating point literals: <code>10.2, .45, +1.5e, 100e-6, 0x1a2.4b5p5</code></li> |
| 61 | <li>string literals: `"ala ma kota", "some\n"</li> |
| 62 | </ul> |
| 63 | <p>For character literals and string literals, escape can be used to put special characters |
| 64 | likes newline, tab. List of the escapes:</p> |
| 65 | <p>Escape | Description | Value |
96 | | `\a` | Alarm | 7 |
97 | | `\b` | Backspace | 8 |
98 | | `\t` | Tab | 9 |
99 | | `\n` | Newline | 10 |
100 | | `\v` | Vertical tab | 11 |
101 | | `\f` | Form feed | 12 |
102 | | `\r` | Carriage return | 13 |
103 | | `\\` | Backslash | 92 |
104 | | `\"` | Double-quote | 34 |
105 | | `\'` | Qoute | 39 |
106 | | `\aaa` | Octal code | Various |
107 | | `\HHH..`|Hexadecimal code | Various |
108 | | |
109 | | ### Expressions |
110 | | |
111 | | The CLRX assembler get this same the operator ordering as in GNU as. |
| 67 | <code>\a</code> | Alarm | 7 |
| 68 | <code>\b</code> | Backspace | 8 |
| 69 | <code>\t</code> | Tab | 9 |
| 70 | <code>\n</code> | Newline | 10 |
| 71 | <code>\v</code> | Vertical tab | 11 |
| 72 | <code>\f</code> | Form feed | 12 |
| 73 | <code>\r</code> | Carriage return | 13 |
| 74 | <code>\\</code> | Backslash | 92 |
| 75 | <code>\"</code> | Double-quote | 34 |
| 76 | <code>\'</code> | Qoute | 39 |
| 77 | <code>\aaa</code> | Octal code | Various |
| 78 | <code>\HHH..</code>|Hexadecimal code | Various</p> |
| 79 | <h3>Expressions</h3> |
| 80 | <p>The CLRX assembler get this same the operator ordering as in GNU as. |
136 | | Binary| !=,<> | 4 | Not equal to |
137 | | Binary| < | 4 | Less than (signed) |
138 | | Binary| <= | 4 | Less or equal (signed) |
139 | | Binary| > | 4 | Greater than (signed) |
140 | | Binary| >= | 4 | Greater or equal (signed) |
141 | | Binary| <@ | 4 | Less than (unsigned) |
142 | | Binary| <=@ | 4 | Less or equal (unsigned) |
143 | | Binary| >@ | 4 | Greater than (unsigned) |
144 | | Binary| >=@ | 4 | Greater or equal (unsigned) |
145 | | Binary| && | 5 | Logical AND |
| 104 | Binary| !=,<> | 4 | Not equal to |
| 105 | Binary| < | 4 | Less than (signed) |
| 106 | Binary| <= | 4 | Less or equal (signed) |
| 107 | Binary| > | 4 | Greater than (signed) |
| 108 | Binary| >= | 4 | Greater or equal (signed) |
| 109 | Binary| <@ | 4 | Less than (unsigned) |
| 110 | Binary| <=@ | 4 | Less or equal (unsigned) |
| 111 | Binary| >@ | 4 | Greater than (unsigned) |
| 112 | Binary| >=@ | 4 | Greater or equal (unsigned) |
| 113 | Binary| && | 5 | Logical AND |
147 | | Binary| ?: | 6 | Choice (this same as C++) |
148 | | |
149 | | 'vert-line' is `|`, and 'dbl-vert-line' is `||`. |
150 | | |
151 | | The `?:` operator have this same meanigful as in C/C++ and performed from |
152 | | right to left side. |
153 | | |
154 | | Symbol refering to some place can be added, subtracted, compared or negated if |
| 115 | Binary| ?: | 6 | Choice (this same as C++)</p> |
| 116 | <p>'vert-line' is <code>|</code>, and 'dbl-vert-line' is <code>||</code>.</p> |
| 117 | <p>The <code>?:</code> operator have this same meanigful as in C/C++ and performed from |
| 118 | right to left side.</p> |
| 119 | <p>Symbol refering to some place can be added, subtracted, compared or negated if |