flat assembler
Message board for the users of flat assembler.

Index > Main > which used more

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 27 Mar 2015, 05:40
Code:
Mov eax,0ffffffffh    
(doesn't change flags)
Code:
xor eax,eax
dec eax    
(if eax is already 0)
Code:
stc
sbb eax,eax    
(if CF is already 1)
Code:
or eax,-1    
(only one instruction)


Last edited by l4m2 on 27 Mar 2015, 13:17; edited 1 time in total
Post 27 Mar 2015, 05:40
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 27 Mar 2015, 06:04
Except the 5 bytes "mov", all these are 3 bytes long, but "or eax, -1" is better because is only one instruction.

But sometimes on initialization I use:
Code:
xor  eax, eax
mov  [somewhere1], eax
dec  eax
mov  [somewhere2], eax
    


The same way, if the CF is already set, SBB can be better.
Post 27 Mar 2015, 06:04
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 27 Mar 2015, 11:07
i have always seen or eax,-1 and thats what i use as well
Post 27 Mar 2015, 11:07
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 27 Mar 2015, 13:10
And what about
Code:
mov dword[ebp-4],0'ffff'ffffh    
Code:
or eax,-1
mov [ebp-4],eax    
Code:
or dword [ebp-4],-1    
(Mainly the latter two)
Post 27 Mar 2015, 13:10
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 27 Mar 2015, 15:13
Code:
mov eax,100    
Code:
lea eax,[word 100]    
Code:
xor eax,eax
mov al,100    
Post 27 Mar 2015, 15:13
View user's profile Send private message Reply with quote
randomdude



Joined: 01 Jun 2012
Posts: 83
randomdude 27 Mar 2015, 15:32
Code:
or dword [ebp-4],-1    

Code:
mov eax,100    
Post 27 Mar 2015, 15:32
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 28 Mar 2015, 00:36
Quote:

which used more

Not sure. I remember I used:
Code:
          xor               eax,eax
          not               eax
    

But now I just follow the simple way:
Code:
          mov               eax,$FFFFFFFF
    

Code:
          mov               eax, dword [_value]

_value:
          dd $FFFFFFFF
    

It works. That is why "mov" exists.
Post 28 Mar 2015, 00:36
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 28 Mar 2015, 04:13
HaHaAnonymous wrote:
Quote:

which used more

Not sure. I remember I used:
Code:
          xor               eax,eax
          not               eax
    

But now I just follow the simple way:
Code:
          mov               eax,$FFFFFFFF
    

Code:
          mov               eax, dword [_value]

_value:
          dd $FFFFFFFF
    

It works. That is why "mov" exists.
MOV can be used when needing
a = 1000;
Post 28 Mar 2015, 04:13
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 28 Mar 2015, 04:17
This topic would be much more interesting if it was discussing loading of constants in ARM code before the v7 architecture gave us MOVW and MOVT.

For x86 it is trivial.
Post 28 Mar 2015, 04:17
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.