Difference between revisions of "AGI Command Reference - Arithmetic Commands"

From AGI Wiki
Jump to navigationJump to search
Line 32: Line 32:
 
=== <br />increment(n); ===
 
=== <br />increment(n); ===
  
<blockquote>The value of the variable Var(n) is incremented by one.
+
<blockquote>The value of the variable Var(n) is incremented by one.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n)+1. If the value is already 255, it is left unchanged.</blockquote>
 
Var(n) = Var(n)+1. If the value is already 255, it is left unchanged.</blockquote>
  
 
=== decrement(n); ===
 
=== decrement(n); ===
  
<blockquote>The value of the variable Var(n) is decremented by one.
+
<blockquote>The value of the variable Var(n) is decremented by one.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n)-1. If the value is 0, it is left unchanged.</blockquote>
 
Var(n) = Var(n)-1. If the value is 0, it is left unchanged.</blockquote>
  
 
=== assign(n, m); ===
 
=== assign(n, m); ===
  
<blockquote>Variable Var(n) is assigned the value m.
+
<blockquote>Variable Var(n) is assigned the value m.</blockquote>
  
'''Examples:'''<br />Var(n) = m</blockquote>
+
<blockquote>'''Examples:'''<br />Var(n) = m</blockquote>
  
 
=== assignv(n, m); ===
 
=== assignv(n, m); ===
  
<blockquote>Variable Var(n) is assigned the value of Var(m).
+
<blockquote>Variable Var(n) is assigned the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(m).</blockquote>
 
Var(n) = Var(m).</blockquote>
  
 
=== addn(n, m); ===
 
=== addn(n, m); ===
  
<blockquote>The value of variable Var(n) is incremented by m.
+
<blockquote>The value of variable Var(n) is incremented by m.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n) + m.</blockquote>
 
Var(n) = Var(n) + m.</blockquote>
  
 
=== addv(n, m); ===
 
=== addv(n, m); ===
  
<blockquote>The value of variable Var(n) is incremented by the value of Var(m).
+
<blockquote>The value of variable Var(n) is incremented by the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
Var(n) = Var(n) + m.
+
Var(n) = Var(n) + m.</blockquote>
  
'''Notes:'''<br />
+
<blockquote>'''Notes:'''<br />
 
Now what happens in the above two commands on 8-bit overflow: does the result wrap over 0 or stays 255? i.e. is 250 + 10 == 4 or 250 + 10 == 255?]</blockquote>
 
Now what happens in the above two commands on 8-bit overflow: does the result wrap over 0 or stays 255? i.e. is 250 + 10 == 4 or 250 + 10 == 255?]</blockquote>
  
 
=== subn(n, m); ===
 
=== subn(n, m); ===
  
<blockquote>The value of Var(n) is decremented by m.
+
<blockquote>The value of Var(n) is decremented by m.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n) - m</blockquote>
 
Var(n) = Var(n) - m</blockquote>
  
 
=== subv(n, m); ===
 
=== subv(n, m); ===
  
<blockquote>The value of Var(n) is decremented by Var(m).
+
<blockquote>The value of Var(n) is decremented by Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
Var(n) = Var(n) - Var(m).
+
Var(n) = Var(n) - Var(m).</blockquote>
  
'''Notes:'''<br />
+
<blockquote>'''Notes:'''<br />
 
Again, what happens when the result must be negative: is 1 - 2 == 255 or 1 - 2 == 0?</blockquote>
 
Again, what happens when the result must be negative: is 1 - 2 == 255 or 1 - 2 == 0?</blockquote>
  
 
=== lindirectn(n, m); ===
 
=== lindirectn(n, m); ===
  
<blockquote>Variable Var(i) where i is the value of Var(n) is assigned a value m.
+
<blockquote>Variable Var(i) where i is the value of Var(n) is assigned a value m.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(Var(n)) = m.</blockquote>
 
Var(Var(n)) = m.</blockquote>
  
 
=== lindirectv(n, m); ===
 
=== lindirectv(n, m); ===
  
<blockquote>Variable Var(i) where i is the value of Var(n) is assigned the value of Var(m).
+
<blockquote>Variable Var(i) where i is the value of Var(n) is assigned the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(Var(n)) = Var(m).</blockquote>
 
Var(Var(n)) = Var(m).</blockquote>
  
 
=== rindirect(n, m); ===
 
=== rindirect(n, m); ===
  
<blockquote>Variable Var(n) is assigned the value of Var(i) where i is the value of Var(m).
+
<blockquote>Variable Var(n) is assigned the value of Var(i) where i is the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(Var(m)).</blockquote>
 
Var(n) = Var(Var(m)).</blockquote>
  
 
=== muln(n, m); ===
 
=== muln(n, m); ===
  
<blockquote>Variable Var(n) is multiplied by m.
+
<blockquote>Variable Var(n) is multiplied by m.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n) * m.</blockquote>
 
Var(n) = Var(n) * m.</blockquote>
  
 
=== mulv(n, m); ===
 
=== mulv(n, m); ===
  
<blockquote>Variable Var(n) is multiplied by the value of Var(m).
+
<blockquote>Variable Var(n) is multiplied by the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
Var(n) = Var(n) * Var(m).<br />
+
Var(n) = Var(n) * Var(m).<br /></blockquote>
  
'''Notes:'''<br />
+
<blockquote>'''Notes:'''<br />
 
What happens on overflow?</blockquote>
 
What happens on overflow?</blockquote>
  
 
=== divn(n, m) ===
 
=== divn(n, m) ===
  
<blockquote>Variable Var(n) is divided by m.
+
<blockquote>Variable Var(n) is divided by m.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
Var(n) = Var(n) / m.</blockquote>  
 
Var(n) = Var(n) / m.</blockquote>  
  
 
=== divv(n, m) ===
 
=== divv(n, m) ===
  
<blockquote>Variable Var(n) is divided by the value of Var(m).
+
<blockquote>Variable Var(n) is divided by the value of Var(m).</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
Var(n) = Var(n) / Var(m).
+
Var(n) = Var(n) / Var(m).</blockquote>
  
'''Notes:'''<br />
+
<blockquote>'''Notes:'''<br />
 
What happens on division by 0?</blockquote>
 
What happens on division by 0?</blockquote>
  
 
=== random(n, m, k) ===
 
=== random(n, m, k) ===
  
<blockquote>Variable Var(k) is assigned a random value in the range between n and m. Now let us consider the commands changing flag values.
+
<blockquote>Variable Var(k) is assigned a random value in the range between n and m. Now let us consider the commands changing flag values.</blockquote>
  
'''Notes:'''<br />
+
<blockquote>'''Notes:'''<br />
 
Remember that a flag can only have a value 0 or 1.</blockquote>
 
Remember that a flag can only have a value 0 or 1.</blockquote>
  
Line 160: Line 160:
 
=== set.v(n) ===
 
=== set.v(n) ===
  
<blockquote>flag(i), where i is the value of var (n), is set to 1.
+
<blockquote>flag(i), where i is the value of var (n), is set to 1.</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
flag(var(n)) = 1.</blockquote>
 
flag(var(n)) = 1.</blockquote>
  
 
=== reset(n) ===
 
=== reset(n) ===
  
<blockquote>flag(n) is set to 0.  
+
<blockquote>flag(n) is set to 0.</blockquote>
  
 
=== reset.v(n) ===
 
=== reset.v(n) ===
  
<blockquote>flag(i), where i is the value of var (n), is set to 0.<br />
+
<blockquote>flag(i), where i is the value of var (n), is set to 0.</blockquote>
<br />
+
 
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
flag(var(n)) = 0.</blockquote>
 
flag(var(n)) = 0.</blockquote>
  
Line 182: Line 182:
 
=== toggle.v(n) ===
 
=== toggle.v(n) ===
  
<blockquote>flag(i), where i is the value of var (n)
+
<blockquote>flag(i), where i is the value of var (n)</blockquote>
  
'''Examples:'''<br />
+
<blockquote>'''Examples:'''<br />
 
flag(var(n)), toggles is value.</blockquote>
 
flag(var(n)), toggles is value.</blockquote>
  

Revision as of 20:06, 21 December 2013

Tutorials Table of Contents
AGI Command Reference Index

Page: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16


Arithmetic Commands
By Chris Cromer


Commands that operate on variables.

 


increment(n);

The value of the variable Var(n) is incremented by one.

Examples:
Var(n) = Var(n)+1. If the value is already 255, it is left unchanged.

decrement(n);

The value of the variable Var(n) is decremented by one.

Examples:
Var(n) = Var(n)-1. If the value is 0, it is left unchanged.

assign(n, m);

Variable Var(n) is assigned the value m.

Examples:
Var(n) = m

assignv(n, m);

Variable Var(n) is assigned the value of Var(m).

Examples:
Var(n) = Var(m).

addn(n, m);

The value of variable Var(n) is incremented by m.

Examples:
Var(n) = Var(n) + m.

addv(n, m);

The value of variable Var(n) is incremented by the value of Var(m).

Examples:
Var(n) = Var(n) + m.

Notes:
Now what happens in the above two commands on 8-bit overflow: does the result wrap over 0 or stays 255? i.e. is 250 + 10 == 4 or 250 + 10 == 255?]

subn(n, m);

The value of Var(n) is decremented by m.

Examples:
Var(n) = Var(n) - m

subv(n, m);

The value of Var(n) is decremented by Var(m).

Examples:
Var(n) = Var(n) - Var(m).

Notes:
Again, what happens when the result must be negative: is 1 - 2 == 255 or 1 - 2 == 0?

lindirectn(n, m);

Variable Var(i) where i is the value of Var(n) is assigned a value m.

Examples:
Var(Var(n)) = m.

lindirectv(n, m);

Variable Var(i) where i is the value of Var(n) is assigned the value of Var(m).

Examples:
Var(Var(n)) = Var(m).

rindirect(n, m);

Variable Var(n) is assigned the value of Var(i) where i is the value of Var(m).

Examples:
Var(n) = Var(Var(m)).

muln(n, m);

Variable Var(n) is multiplied by m.

Examples:
Var(n) = Var(n) * m.

mulv(n, m);

Variable Var(n) is multiplied by the value of Var(m).

Examples:
Var(n) = Var(n) * Var(m).

Notes:
What happens on overflow?

divn(n, m)

Variable Var(n) is divided by m.

Examples:
Var(n) = Var(n) / m.

divv(n, m)

Variable Var(n) is divided by the value of Var(m).

Examples:
Var(n) = Var(n) / Var(m).

Notes:
What happens on division by 0?

random(n, m, k)

Variable Var(k) is assigned a random value in the range between n and m. Now let us consider the commands changing flag values.

Notes:
Remember that a flag can only have a value 0 or 1.

set(n)

flag(n) is set to 1.


set.v(n)

flag(i), where i is the value of var (n), is set to 1.

Examples:
flag(var(n)) = 1.

reset(n)

flag(n) is set to 0.

reset.v(n)

flag(i), where i is the value of var (n), is set to 0.

Examples:
flag(var(n)) = 0.

toggle(n)

flag(n) toggles its value.

toggle.v(n)

flag(i), where i is the value of var (n)

Examples:
flag(var(n)), toggles is value.

 

Page: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16

 

Tutorials Table of Contents
AGI Command Reference Index

< Previous: IndexNext: Commands to Load and unLoad Resources >