Code Monkey home page Code Monkey logo

Comments (4)

aguinet avatar aguinet commented on August 23, 2024 1

By the way, for your original expression, you can use "lazy evaluation" using Arybo expressions. This is a less documented feature, I've got to put it in the final documentation.

Here is the example script:

from arybo.lib import MBA
from arybo.lib.mba_exprs import ExprBV, eval_expr

def transform(x):
        return (((((((- (((((((((((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) & ((((((- x) & 0xffffffff) + 0x2C) & 0xffffffff) | 0xC4) & 0xffffffff)) & 0xffffffff) ^ ((x + 0xFFFFFFD4) & 0xffffffff)) & 0xffffffff) + 0x80403064) & 0xffffffff) ^ 0xED) & 0xffffffff) | 0x403053) & 0xffffffff) & 0xff)) & 0xff) + 0x7E) & 0xff) & 0xff) << 0) | ((0x0 & 0xffffff) << 8))

mba = MBA(32)
x = mba.var('x')
x = ExprBV(x)

f = transform(x)
print(f)
print(eval_expr(f))

This outputs:

Vec([
1,
1,
((x0 * x1) + x0 + x1),
((x0 * x2) + (x1 * x2) + (x0 * x1 * x2) + x2 + 1),
((x0 * x1) + x0 + x1),
((x2 * x3) + (x0 * x2 * x3) + (x1 * x2 * x3) + (x2 * x3 * x4) + (x0 * x1 * x2 * x3) + (x0 * x2 * x3 * x4) + (x1 * x2 * x3 * x4) + (x0 * x1 * x2 * x3 * x4)),
0,
((x2 * x3 * x5 * x6) + (x0 * x2 * x3 * x5 * x6) + (x1 * x2 * x3 * x5 * x6) + (x2 * x3 * x4 * x5 * x6) + (x0 * x1 * x2 * x3 * x5 * x6) + (x0 * x2 * x3 * x4 * x5 * x6) + (x1 * x2 * x3 * x4 * x5 * x6) + (x0 * x1 * x2 * x3 * x4 * x5 * x6) + 1),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
])

from arybo.

cynecx avatar cynecx commented on August 23, 2024

I have reduced the testcase to this small expression:

from arybo.lib import MBA

def transform(x):
    a = 1 - x
    b = x + 1
    c = a ^ b
    return c

mba = MBA(32)
x = mba.var('x')

print (transform(x))

from arybo.

aguinet avatar aguinet commented on August 23, 2024

Hello!

If you try it on 16 bits this will work in a decent amount of time. I think the expression start to be become too big above 16 bits to handle.
By the way, I am working on a new tree-based storage for boolean expression, that can consume more memory but be really more efficient in some cases!

from arybo.

cynecx avatar cynecx commented on August 23, 2024

Thank you :) I guess that will do it for now.

from arybo.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.