Mulscale: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
One (talk | contribs)
No edit summary
extended this a bit
Line 1: Line 1:
'''mulscale''' <res> <eax> <edx> <ecx>
'''mulscale''' ''<res>'' <eax> <edx> <ecx>


The formula is<br/>  
The formula is<br/>  
res=(eax*edx)>>ecx
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.
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'' ''cosang'' 14


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]
[[Category:Gamevar manipulation]]
[[Category:Gamevar manipulation]]

Revision as of 07:27, 4 August 2010

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 cosang 14