Subv
From AGI Wiki
Revision as of 21:48, 23 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''subv''' command subtracts the value of one variable from another and stores the result in the first variable. == Syntax == subv(var vA, var...")
The subv command subtracts the value of one variable from another and stores the result in the first variable.
Syntax
subv(var vA, var vB);
vA = vA - vB;
vA -= vB;
Remarks
Because variables are 8 bit unsigned numbers, if the result of the subtraction is less than 0, the result 'wraps around'. For example, if v50 currently equals 20 and v51 equals 25, the statement:
subv(v50, v51);
will result in a value for v50 of 251 (20 - 25 = -5; -5 + 256 = 251).
Possible Errors
None.
Example
Code:
<syntaxhighlight lang="agi"> v50 = 75; v51 = 60; subv(v50, v51); [ v50 now equals 15 v50 = v50 - v51; [ v50 now equals 211 (-45 + 256) v50 -= v51; [ v50 now equals 151 </syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 8 (0x08 hex) |