flat assembler
Message board for the users of flat assembler.

Index > Main > mov [xxx+xxx*x], 0

Author
Thread Post new topic Reply to topic
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
what are the possible values/expressions there? and how do you call that? displacement?

lea eax,[xxx+xxx*x]
mov [xxx+xxx*x], 0

i can just at max plus and mult one time? also, it doesnt let me set > *8, neither *3 or *5?

i saw intel manual and i cant find the XXX+XXX*X formula, just XXX+XXX or XXX*X. explain me!!

_________________
Sorry if bad english.
Post 27 Sep 2011, 23:31
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Teehee wrote:

what are the possible values/expressions there? and how do you call that? displacement?

You mean the X's ?
Post 27 Sep 2011, 23:58
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Teehee wrote:

lea eax,[xxx+xxx*x]
mov [xxx+xxx*x], 0


Code:
lea eax,[xxx+yyy*Z] 
mov [data_type_whose_size_is_Z] [xxx+yyy*Z], 0 

    
Post 28 Sep 2011, 00:01
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 764
Location: Massachusetts, USA
bitshifter
I think maybe he wants to learn the LEA multiplier tricks?
Post 28 Sep 2011, 00:03
View user's profile Send private message Reply with quote
Fred



Joined: 22 Oct 2010
Posts: 39
Fred
[reg + reg * (1,2,4,8) + const]

I think.
Post 28 Sep 2011, 11:39
View user's profile Send private message Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
bitshifter wrote:
I think maybe he wants to learn the LEA multiplier tricks?

no no!! i just wanna know why i cannot use others patterns than XXX+YYY*Z. And why i cant find that in the intel manuals Razz

Fred wrote:
[reg + reg * (1,2,4,8 ) + const]

I think.

hmmm it seems to accept that const too!

so its XXX+YYY*Z+C !! Very Happy

_________________
Sorry if bad english.
Post 28 Sep 2011, 12:25
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2913
Location: [RSP+8*5]
bitRAKE
The instruction encoding has limited variability - this is outlined in the manual. Three bits for X and Y, two bits for Z, and an extension dword for C.
Post 28 Sep 2011, 13:15
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2141
Location: Estonia
Madis731
The "LEA-trick" mentioned means you can use LEA to multiply with small constants easily
where REG1=REG2=REG3 and C=0 in LEA REG1,[REG2*{0|1}+REG3*{1|2|4|8}+C]
For example:
lea eax,[eax*{0|1}+eax*{1|2|4|8}]
combining you can replace MUL (which is sometimes more expensive) with LEA in a few cases:
mul eax,{0,1,2,3,4,5,8,9}

You can see that it is impossible to encode 6 or 7 with this trick, but there are two ways to encode 1 and 2.
It is not very efficient to use LEA to multiply by 0,1,2,4 or 8 (ADD and SHL are better) so you are left with 3,5 and 9.

FASM allows this simple markup:
Code:
lea eax,[eax*3]
lea eax,[eax*5]
lea eax,[eax*9]
    
Post 28 Sep 2011, 17:47
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
^^Good for obfuscation Wink
Post 28 Sep 2011, 21:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.