Addv
From AGI Wiki
Jump to navigationJump to searchThe addv command adds the values of two variables, and stores the result in the first variable.
Syntax
addv(var vA, var vB);
vA = vA + vB;
vA += vB;
Remarks
Because variables are 8 bit unsigned numbers, if the result of the addition exceeds 255, the result 'wraps around'. For example, if v50 currently equals 200, and v51 has a value of 60, the statement:
addv(v50, v51);
will result in a value for v50 of 4 (200 + 60 = 260; 260 - 256 = 4). This can be represented mathematically as vA = (vA + vB) % 0x100.
Possible Errors
None.
Example
Code:
<syntaxhighlight lang="agi"> v50 = 100; v51 = 100; addv(v50, v51); [ v50 now equals 200 v50 = v50 + v51; [ v50 now equals 44 (300 - 256) v50 += v51; [ v50 now equals 144 </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 6 (0x06 hex) |