News:

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

MOV and expression source

Started by frktons, September 06, 2010, 10:18:15 PM

Previous topic - Next topic

Magnum

Quote from: zemtex on September 06, 2010, 10:58:33 PM
Quote from: frktons on September 06, 2010, 10:43:45 PM
Quote from: zemtex on September 06, 2010, 10:24:51 PM


Consider LEA as a "trickster", it is not meant to be used regularly for that purpose. You can only multiply registers with 2, 4 and 8 using lea. It is just an option if you want to simplify things every now and then.

Lea is more versatile than that.
LEA can multiply a register by 2,3,4,5,8, and 9.


lea          ebx,[ebx+ebx*8]

Have a great day,
                         Andy

zemtex

Quote from: Magnum on September 07, 2010, 02:03:34 AM
Quote from: zemtex on September 06, 2010, 10:58:33 PM
Quote from: frktons on September 06, 2010, 10:43:45 PM
Quote from: zemtex on September 06, 2010, 10:24:51 PM


Consider LEA as a "trickster", it is not meant to be used regularly for that purpose. You can only multiply registers with 2, 4 and 8 using lea. It is just an option if you want to simplify things every now and then.

Lea is more versatile than that.
LEA can multiply a register by 2,3,4,5,8, and 9.


lea          ebx,[ebx+ebx*8]


The use of constants when multiplying must be 2, 4 or 8.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

frktons

Quote from: zemtex on September 06, 2010, 10:24:51 PM
Consider LEA as a "trickster", it is not meant to be used regularly for that purpose. You can only multiply registers with 2, 4 and 8 using lea. It is just an option if you want to simplify things every now and then.

Lea is more versatile than that.
LEA can multiply a register by 2,4 or 8.

lea          ebx,[ebx+ebx*8]

The use of constants when multiplying must be 2, 4 or 8.

:lol Magnum is the name on an icecream and he was so sweet and cold to add
some odd numbers to yours.  :lol

Now I've make the sentence in bold characters, just to remember it.  :U

Frank
Mind is like a parachute. You know what to do in order to use it :-)

Tedd

#18
The 'scale' value can only 2, 4, or 8, but you may also use lea to get the effect of multiplying by 3, 5, and 9.

lea eax,[2*eax + eax]  { (2*n + n) = 3*n }
lea eax,[4*eax + eax]  { (4*n + n) = 5*n }
lea eax,[8*eax + eax]  { (8*n + n) = 9*n }


With a little extra work, you can also get 7 by copying the value, negating it, and then using that in the 'base' part.




Addressing form is [scale*index + base + displacement] -- all complex forms must be reducible to this form for the assembler to allow it. (Complex constant expressions are allowed only if they can be reduced to a single constant at assembly time, i.e. all values are known.)
No snowflake in an avalanche feels responsible.