Mulscale - EDukeWiki

# Mulscale

From EDukeWiki

mulscale <res> <eax> <edx> <ecx>

The formula is
res=(eax*edx)>>ecx

The intermediate value is computed using 64 bits to prevent overflow and the result is 32 bits wide. This is a math function which is implemented in assembler programing language because it makes the calculation faster.

The primary use of this function is in calculations involving scaled integers, that is, integers that have a binary point somewhere by convention. For example, the trigonometric functions Sin and Cos use a scaling of 1:16384, corresponding to a 14 bit shift. So, if you wanted to multiply some length (say, dx) by a cosine value (say, cosang), you could write

     mulscale dx dx cosang 14

Retrieved from "http://wiki.eduke32.com/w/index.php?title=Mulscale&oldid=10723"
Categories:

- EDuke32 specific commands
- Gamevar manipulation