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: 648
l4m2
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: 3500
Location: Bulgaria
JohnFound
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
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: 648
l4m2
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: 648
l4m2
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
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: 1180
Location: Unknown
HaHaAnonymous
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: 648
l4m2
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: 17287
Location: In your JS exploiting you and your system
revolution
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.