News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

how to divide or multiply percentages in masm32

Started by mahmudkais, September 20, 2009, 10:15:25 PM

Previous topic - Next topic

mahmudkais

hello

how to divide or multiply percentages in masm32 ??

some example code please to learn ??

thanks

mahmudkais

i found it and it is simple

1000 * 0.006  =   (1000 * 6 )/1000  = 6


MOV   EAX, 1000
mov ebx,6
mul   ebx
mov ebx,1000

div   ebx


thanks


hutch--

mahmudkais,

If you are going to be doing much number crunching, have a look at Ray Filiatreault's floating point maths library included in the masm32 sdk, simple interger maths have their place but for more complex work the floating point capacity is a lot more powerful.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

mahmudkais


donkey

If your just doing simple percentages the FPU is a bit of overkill, mostly they can be done using integer math as you posted above. To save a few clock cycles you can get rid of the DIV instruction...

http://blogs.msdn.com/devdev/archive/2005/12/12/502980.aspx

Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

BlackVortex

There is a tiny tool that does this, Magic Divider. I mean breaks down the divisions  to multiplication using a constant. Attached.