You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The <codeclass="65c816_asar">warn xkas</code> command determines whether Asar should throw warnings on behavior that is known to be different between xkas and Asar. Use <code>warn xkas on</code> to enable these warnings and <code>warn xkas off</code> to disable them. It's recommended to only enable them when not using <ahref="#xkas">xkas compatibility mode</a>. Note that some behavioral changes throw warnings or errors regardless of this setting.
1669
-
<h4id="math-pri">math pri</h4>
1670
-
<pre><codeclass="65c816_asar">math pri {on/off}</code></pre>
1671
-
The <codeclass="65c816_asar">math pri</code> command tells Asar which order of operations to use in math experssions. When set to off (default), Asar uses left-to-right math, just like xkas v0.06. When set to on, Asar follows the conventional oder of operations (exponentiation before multiplication & division, multiplication & division before addition & subtraction etc.). Parentheses can be used in either mode and tell Asar to calculate the expression inside first. For most intents and purposes, working with this flag enabled is more practical and predictable. It is disabled by default solely for the purpose of xkas backwards compatibility, unless <codeclass="65c816_asar">@asar 1.9</code> or a higher version is specified at the start of the file, which will change the default to <codeclass="65c816_asar">math pri on</code>. When writing patches specifially for Asar, it is recommended to always enable this flag.
The <codeclass="65c816_asar">math round</code> command tells Asar which rounding behavior to use in math expressions. When set to on (default), Asar truncates all numbers immediately, whereas when set to off, Asar only truncates numbers whenever they need to be cast to an integer type. Note that having this flag enabled will make it practically impossible to work with floating point numbers since calculations will lead to unexpected and impractical results. It is the default setting solely for the purpose of xkas backwards compatibility. When writing patches specifially for Asar, it is recommended to always disable this flag.
1680
-
<pre><codeclass="65c816_asar">math round on
1681
-
; 1.75 is immediately truncated to 1, resulting in (3/4)+1
1682
-
; 3/4 would result in 0.75, which is immediately truncated to 0, resulting in 0+1
1683
-
; Thus leading to the final result of "db 1"
1684
-
db (3/4)+1.75
1685
-
1686
-
; !some_number contains 0 after this line
1687
-
!some_number #= 0.75
1688
-
1689
-
math round off
1690
-
; As expected will result in 0.75+1.75, which will result in 2.5
1691
-
; 2.5 is truncated to 2
1692
-
; Thus leading to the final result of "db 2"
The <codeclass="65c816_asar">namespace nested</code> command enables (<codeclass="65c816_asar">on</code>) or disables (<codeclass="65c816_asar">off</code>) nested namespaces. The default is <codeclass="65c816_asar">off</code>. See section <ahref="#namespaces">Namespaces</a> for details.<br/><br/>
Math is supported in all opcodes, functions and labels. By default, Asar uses left-to-right math for backwards-compatibility with xkas which means that it ignores operator precedence.
1898
-
<pre><codeclass="65c816_asar">lda #6*2+5 ; the same as "lda #17"
1899
-
lda #5+6*2 ; the same as "lda #22"</code></pre>
1900
-
This behavior can be changed by using the command <codeclass="65c816_asar">math pri on</code>, which makes Asar apply conventional prioritization rules in all math statements. (See <ahref="#math-pri">math pri</a>)
1901
-
<pre><codeclass="65c816_asar">math pri on
1902
-
1903
-
lda #6*2+5 ; the same as "lda #17"
1904
-
lda #5+6*2 ; the same as "lda #17"</code></pre>
1905
-
In both modes, Asar supports parentheses for explicit control over the order of operations.
1906
-
<pre><codeclass="65c816_asar">math pri on
1907
-
1908
-
lda #5+6*2 ; the same as "lda #17"
1867
+
Math is supported in all opcodes, functions and labels. Asar applies the conventional operator prioritization rules (PEMDAS) in math expressions and supports parentheses for explicit control over the order of operations.
1868
+
<pre><codeclass="65c816_asar">lda #5+6*2 ; the same as "lda #17"
1909
1869
lda #(5+6)*2 ; the same as "lda #22"</code></pre>
1910
1870
Math statements in Asar support the following operators:<br/><br/>
<td>Takes the identifier of a struct as a parameter and returns the base size of that struct (without any extension structs). Throws an error if a struct with that name doesn't exist. For backwards compatibility, the identifier can be surrounded with quotes.</td>
2695
+
<td>Takes the identifier of a struct as a parameter and returns the base size of that struct (without any extension structs).</td>
<td>Takes the identifier of a struct as a parameter and returns the object size of that struct. In the case of an extended struct, this will be the base size of the struct plus the size of its largest extension struct. Throws an error if a struct with that name doesn't exist. For backwards compatibility, the identifier can be surrounded with quotes.</td>
2709
+
<td>Takes the identifier of a struct as a parameter and returns the object size of that struct. In the case of an extended struct, this will be the base size of the struct plus the size of its largest extension struct. Throws an error if a struct with that name doesn't exist.</td>
<td>Takes a given label and calculates the distance between it and the next label. It will throw a warning if the distance exceeds 0xFFFF or is the last label in the targeted assembly.</td>
2723
+
<td>Takes a given label and calculates the distance between it and the next label. It will throw a warning if the distance exceeds 0xFFFF or is the last label in the targeted assembly.</td>
All built-in functions can be overridden by user-defined functions. Prepending an underscore (for example: <codeclass="65c816_asar">_read1()</code>) leads to the original function, which can be used to make an overridden function call its original function.
db readfilenormalizd("datafile.bin", 0)</code></pre>
@@ -3295,7 +3253,7 @@ <h4 id="print">print</h4>
3295
3253
</tr>
3296
3254
<tr>
3297
3255
<td><code>double(x[, precision])</code></td>
3298
-
<td>Prints x as a decimal number with precision decimal places (default: 5), where x can be any math statement. Affected by the <ahref="#math-round">math round</a> setting.</td>
3256
+
<td>Prints x as a decimal number with precision decimal places (default: 5), where x can be any math statement.</td>
0 commit comments