Changes between Version 1 and Version 2 of ClrxAsmSyntax


Ignore:
Timestamp:
10/27/15 20:41:43 (8 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ClrxAsmSyntax

    v1 v2  
    11{{{
    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
     5GNU 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
    118statements. Statement can be the symbol's assignment, assembler's pseudo-operation
    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,
     13likewise 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:
     17begins from <code>/*</code> and terminates at <code>*/</code>.</p>
     18<p>Names of pseudo-operations, macro names, processors instructions and other names
    3019(for example: argument type, gpu device type) are case-insensitive. Symbol names are
    31 case-sensitive.
    32 
    33 ### Symbols
    34 
    35 CRLX assembler operates on the symbols. The symbol is value that can be a absolute value or
     20case-sensitive.</p>
     21<h3>Symbols</h3>
     22<p>CRLX assembler operates on the symbols. The symbol is value that can be a absolute value or
    3623it can refer to some place in binary code. Special symbol that is always defined refers to
    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
     24current place of a binary code. This is <code>.</code> and is called in this manual as output counter.
     25Symbol names can contains alphanumeric characters, <code>.</code> and <code>_</code>. First character
     26must not be a digit. This same rules concerns a labels.</p>
     27<p>Label are symbol that can not be redefined.
     28Labels precedes statement and can occurred many times. Like that:</p>
     29<p><code>label1: init: v_add_i32 v1, v2
     30end:  s_endpgm</code></p>
     31<p>Special kind of the label is local labels. They can be used only locally. The identifier
    5032of local labels can have only digits. In contrast, local labels can to be
    5133redefined many times.
    5234In source code reference can be to previous or next local label by
    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)
     35adding <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
     39type of the section. Main program code is in the <code>.text</code> section which holds
     40program's instructions. Section <code>.rodata</code> holds read-only data (mainly constant data)
    6441that can be used by program. Section can be divided by type of the access.
    6542The most sections are writeable (any data can be put into them) and
    66 addressable (we can define symbols inside these sections or move forward).
    67 
    68 Absolute section is only addressable section. It can be used for defining structures.
     43addressable (we can define symbols inside these sections or move forward).</p>
     44<p>Absolute section is only addressable section. It can be used for defining structures.
    6945In absolute section output counter can be moved backward (this is special exception
    70 for absolute section).
    71 
    72 Any symbol that refer to some code place refer to sections.
    73 
    74 ### Literals
    75 
    76 CLRX assembler treats any constant literals as 64-bit value. Assembler honors
     46for absolute section).</p>
     47<p>Any symbol that refer to some code place refer to sections.</p>
     48<h3>Literals</h3>
     49<p>CLRX assembler treats any constant literals as 64-bit value. Assembler honors
    7750C/C++ literal syntax. Special kind of literal are floating point literals.
    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
     51They can be used only in <code>.half</code>, <code>.single</code>, <code>.float</code>, <code>.double</code> pseudo-operations
     52or 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
     64likes newline, tab. List of the escapes:</p>
     65<p>Escape   |  Description    | Value
    9566:-------:|-----------------|-------------
    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.
    11281CLRX assembler treat any literal or symbol's value as 64-bit integer value.
    113 List of the operators:
    114 
    115 Type  | Operator | Order | Description
     82List of the operators:</p>
     83<p>Type  | Operator | Order | Description
    11684------|:--------:|:-----:|--------------------
    11785Unary |    -     |   1   | Negate value
     
    12492Binary|    %     |   2   | Signed remainder
    12593Binary|    %%    |   2   | Unsigned remainder
    126 Binary|    <<    |   2   | Left shift
    127 Binary|    >>    |   2   | Unsigned right shift
    128 Binary|    >>>   |   2   | Signed right shift
    129 Binary|    &     |   3   | Binary AND
     94Binary|    &lt;&lt;    |   2   | Left shift
     95Binary|    &gt;&gt;    |   2   | Unsigned right shift
     96Binary|    &gt;&gt;&gt;   |   2   | Signed right shift
     97Binary|    &amp;     |   3   | Binary AND
    13098Binary| vert-line|   3   | Binary OR
    13199Binary|    ^     |   3   | Binary XOR
     
    134102Binary|    -     |   3   | Subtraction
    135103Binary|    ==    |   4   | Equal to
    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
     104Binary| !=,&lt;&gt;    |   4   | Not equal to
     105Binary|   &lt;      |   4   | Less than (signed)
     106Binary|   &lt;=     |   4   | Less or equal (signed)
     107Binary|   &gt;      |   4   | Greater than (signed)
     108Binary|   &gt;=     |   4   | Greater or equal (signed)
     109Binary|   &lt;@     |   4   | Less than (unsigned)
     110Binary|   &lt;=@    |   4   | Less or equal (unsigned)
     111Binary|   &gt;@     |   4   | Greater than (unsigned)
     112Binary|   &gt;=@    |   4   | Greater or equal (unsigned)
     113Binary|   &amp;&amp;     |   5   | Logical AND
    146114Binary|dbl-vert-line|   5   | Logical OR
    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
     115Binary|   ?:     |   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
     118right to left side.</p>
     119<p>Symbol refering to some place can be added, subtracted, compared or negated if
    155120final result of the expression can be represented as place of the code or absolute value
    156121(without refering to any place). An assembler performs this same operations
    157122on the sections during evaluating an expression. Division, modulo,
    158 binary operations (except negation), logical operations is not legal.
    159 }}}
     123binary operations (except negation), logical operations is not legal.</p>}}}