flat assembler
Message board for the users of flat assembler.

Index > Main > Binary simplification

Author
Thread Post new topic Reply to topic
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 24 Mar 2008, 05:15
How would you simplify this:
Code:
    shr     ebp, 5
    add     ebp, 7
    shl     ebp, 2
    sub     ebp, 8
    

To make it use operators like 'and' and 'or'. I have read about this, but I can't understand how..
Post 24 Mar 2008, 05:15
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20449
Location: In your JS exploiting you and your system
revolution 24 Mar 2008, 05:36
Code:
    shr     ebp, 5 ;ebp/32
    add     ebp, 7 ;ebp/32+7
    shl     ebp, 2 ;(ebp/8)&0xfffffffc+28
    sub     ebp, 8 ;ebp/8+20    
So:
Code:
    shr ebp,3
    and ebp,0xfffffffc
    add ebp,20    
Post 24 Mar 2008, 05:36
View user's profile Send private message Visit poster's website Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 24 Mar 2008, 05:46
Wow, thanks! I'll definitely start learning some of those tricks.
Post 24 Mar 2008, 05:46
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 24 Mar 2008, 14:12
Architecture wise you can simplify that instruction sequence even further with...
Code:
SHR ebp,5
LEA ebp,[ebp*4+20]
    
Post 24 Mar 2008, 14:12
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 24 Mar 2008, 14:33
No, I think I'll stick with:
Code:
 shr   ebp, 3
 add  ebp, 20
    
Post 24 Mar 2008, 14:33
View user's profile Send private message Visit poster's website Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 24 Mar 2008, 23:35
Correct(127):
127/32{SHR x,5} = 3
+ 7 {ADD x,7} = 10
* 4 {SHL x,2} = 40
- 8 {SUB x,8} = 32

Fail(127):
127/8 {SHR x,3} = 15
+ 20 {ADD x,20} = 35

AlexP
Its NOT equivalent to your initial sequence of instructions.
Post 24 Mar 2008, 23:35
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 24 Mar 2008, 23:43
Should have specified, it fits the purpose of my code.
Post 24 Mar 2008, 23:43
View user's profile Send private message Visit poster's website Reply with quote
ic2



Joined: 19 Jan 2008
Posts: 75
ic2 25 Mar 2008, 03:54
I always thought the usage of LEA shows a lot of garbage code in the registers but provide a added special something specially when dealing with encryption. Just wondering out loud. I'll talk logic by September...
Post 25 Mar 2008, 03:54
View user's profile Send private message Reply with quote
daniel.lewis



Joined: 28 Jan 2008
Posts: 92
daniel.lewis 25 Mar 2008, 05:27
Very Happy I hope your idea is what you think it is.

I stopped worrying about encryption after I decided my Beale Ciphers were strong enough.

_________________
dd 0x90909090 ; problem solved.
Post 25 Mar 2008, 05:27
View user's profile Send private message Reply with quote
AlexP



Joined: 14 Nov 2007
Posts: 561
Location: Out the window. Yes, that one.
AlexP 25 Mar 2008, 18:36
Depends, what source are you using for key?
Post 25 Mar 2008, 18:36
View user's profile Send private message Visit poster's website Reply with quote
daniel.lewis



Joined: 28 Jan 2008
Posts: 92
daniel.lewis 25 Mar 2008, 23:36
Very Happy If I told you I'd have to kill you.

Let me say though, that any data can be used to cipher something. Any data from anywhere on any disk or network. I recommend a widely varied set of data from different places if you really care.

_________________
dd 0x90909090 ; problem solved.
Post 25 Mar 2008, 23:36
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.