Mul.v

From AGI Wiki
Revision as of 17:23, 11 April 2019 by Andrew Korson (talk | contribs) (Created page with "The '''mul.v''' command multiplies two variables and stores the result in the first. == Syntax == mul.v(var vA, var vB);<br /> vA = vA * vB;<br />...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The mul.v command multiplies two variables and stores the result in the first.

Syntax

mul.v(var vA, var vB);
vA = vA * vB;
vA *= vB;

Remarks

Because variables are 8 bit unsigned numbers, if the result of the multiplication exceeds 255, the result 'wraps around'. For example, if v50 currently equals 200, and v51 equals 3, the statement: mul.v(v50, v51); will result in a value for v50 of 88 (200 * 3 = 600; 600 - 512 = 88). This can be represented mathematically as vA = (vA * vB) mod 256.

Note that this command uses the 'dot' notation (i.e. mul.v vs. mulv) unlike the original set of mathematical commands.

Possible Errors

None.

Example

Code:

<syntaxhighlight lang="agi"> v50 = 40; v51 = 5; mul.v(v50, v51); [ v50 now equals 200 v50 = v50 * v51; [ v50 now equals 232 (1000 - 256 * 3) v50 *= v51; [ v50 now equals 136 (1160 - 256 * 4) </syntaxhighlight>

Technical Information

Required Interpreter Version: Available in version 2.411 and above.
Byte-Code Value: 166 (0xA6 hex)

See Also

Mathematical Commands
mul.n