Subv
From Sierra WikiNew
Jump to navigationJump to search
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:
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
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 8 (0x08 hex) |