Well today instead of trying to code something that I might didn't understand fully I decided to learn more asm. If your new to asm I suggest reading "Assembly Language step by step" by Jeff Duntemann.

It's a good read for those new to asm but it's only talks about 32-bit concerning Linux. Guess you can improvise win32 then.....hehe ISBN 0-471-37523-3

Back to the subject thou. I learn today about asm how to multiply & divide in a faster way. Knowing that I have two another instructions "SAL || SHL". Example: if eax is == 20 and I wanted to * by 2

the "MUL" takes on at least Pentiums 13 clock cycles

where a "SHL" takes only 2 clock cycles so a "SHL" is faster than "MUL"

Hmm...if "SHL" multiplies a binary value by powers of 2 then a [ SHR || SAR] must divide a binary value by powers of 2 then right.

Now those noobies out there what do you learn about asm today?

If still :confused: check my signature :)

It's a good read for those new to asm but it's only talks about 32-bit concerning Linux. Guess you can improvise win32 then.....hehe ISBN 0-471-37523-3

Back to the subject thou. I learn today about asm how to multiply & divide in a faster way. Knowing that I have two another instructions "SAL || SHL". Example: if eax is == 20 and I wanted to * by 2

```
mov eax, 20
```

mov ecx, 2

mul ecx

the "MUL" takes on at least Pentiums 13 clock cycles

where a "SHL" takes only 2 clock cycles so a "SHL" is faster than "MUL"

```
mov eax, 20
```

shl eax,1

Hmm...if "SHL" multiplies a binary value by powers of 2 then a [ SHR || SAR] must divide a binary value by powers of 2 then right.

Now those noobies out there what do you learn about asm today?

If still :confused: check my signature :)

I learnt that you can push a REAL4 to a 32bit register (real4 is 32 bits), and pop it and still have the decimal intact. What use is it since normal asm math (add, sub, mul, div) will destroy the decimal/number?

Instead of using the FPU to transfer a number to a register, you can push/pop or mov edx, var_real. Still not much of a use I can see unless someone wants to fill this noob1e in or correct me. I guess storing the variable into a register to use the FPU to do the math would be faster code?

Instead of using the FPU to transfer a number to a register, you can push/pop or mov edx, var_real. Still not much of a use I can see unless someone wants to fill this noob1e in or correct me. I guess storing the variable into a register to use the FPU to do the math would be faster code?

If you want to speed up your divisions there is a utility called "Magic devider" by The Svin that I use to get the magic number. It works quite well and is much faster than DIV:

devide by 15:

MagicNumber = 2290649225

mov eax,X

mov edx, MagicNumber

mul edx

SHR edx, 3

devide by 15:

MagicNumber = 2290649225

mov eax,X

mov edx, MagicNumber

mul edx

SHR edx, 3

drarem

One of the uses of transfering a REAL4 to a register is to make signed comparisons which are faster than using the FPU for similar comparisons.

It can also be used to get a quick estimate of the size of a number, and determine if it is positive or negative.

If you are not yet familiar with the format of floating point numbers, have a look at Chap.2 of the following tutorial.

http://www.masmforum.com/website/tutorials/fptute/index.html

Raymond

One of the uses of transfering a REAL4 to a register is to make signed comparisons which are faster than using the FPU for similar comparisons.

It can also be used to get a quick estimate of the size of a number, and determine if it is positive or negative.

If you are not yet familiar with the format of floating point numbers, have a look at Chap.2 of the following tutorial.

http://www.masmforum.com/website/tutorials/fptute/index.html

Raymond

I learnt that you can push a REAL4 to a 32bit register (real4 is 32 bits), and pop it and still have the decimal intact. What use is it since normal asm math (add, sub, mul, div) will destroy the decimal/number?

Because REAL4 or a IEEE float point have a specific format, in simple numbers you can have signed and unsigned operations, but when you work with floating points, you can not use the same operations, for example, when you learn to add, you do:

55

+12

-----

67 (Hey I know how to add... my profile say no... ok ok.. some times I fail)

But how you will add?

55.234234234

+12

-----

67

Because you dont know in that moment what to do with the point, is near the same for the CPU, the processor have their operations for integer aritmetic, but when you work with presicion numbers (with a point), the representation of the numbers is diferent, then you need use others methods.

Hope I undrstand what you question ;)

Have a nice day or night.