Mulscale: Difference between revisions
Jump to navigation
Jump to search
Helixhorned (talk | contribs) extended this a bit |
Helixhorned (talk | contribs) fix my example. |
||
Line 9: | Line 9: | ||
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 | 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'' ''cosang'' 14 | '''mulscale''' ''dx'' ''dx'' ''cosang'' 14 | ||
[[Category:EDuke32 specific commands]] | [[Category:EDuke32 specific commands]] | ||
[[Category:Gamevar manipulation]] | [[Category:Gamevar manipulation]] |
Revision as of 10:27, 21 April 2012
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