chyyuu / distorm

Automatically exported from code.google.com/p/distorm
GNU General Public License v3.0
0 stars 0 forks source link

Python interface #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
No modifiedFlagsMask et.al access from python.
Also wouldn't it be better if the mask matches the actual flags bit positions?  
That way you may do bitwise ops with the actual EFLAGS register value. If not 
in C maybe in the py iface? 

r = {}
for i in range(0,0x100):
    CF = 1<<0
    PF =  1<<2
    AF =  1<<4
    ZF =  1<<6
    SF =  1<<7
    IF =  1<<9
    DF =  1<<10
    OF =  1<<11

    D_ZF = 1 # Zero */
    D_SF = 2 # Sign */
    D_CF = 4 # Carry */
    D_OF = 8 # Overflow */
    D_PF = 0x10 # Parity */
    D_AF = 0x20 # Auxilary */
    D_DF = 0x40 # Direction */
    D_IF = 0x80 # Interrupt */

    flags = 0;
    if i & D_ZF:
        flags |= ZF
    if i & D_SF:
        flags |= SF
    if i & D_CF:
        flags |= CF
    if i & D_OF:
        flags |= OF
    if i & D_PF:
        flags |= PF
    if i & D_AF:
        flags |= AF
    if i & D_DF:
        flags |= DF
    if i & D_IF:
        flags |= IF

    r[i] = flags
print repr(r)

What version of diStorm are you using?
distorm3-3 python2.7 linux

Original issue reported on code.google.com by felipe.a...@gmail.com on 21 May 2013 at 3:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hey Felipe,
the reason I didn't do 1 to 1 map is because some flags exceed 8 bits 
representation and I'm cheap on memory.
However, for Python it might be convenient.
When I get the time I might add it, thanks.

Original comment by distorm@gmail.com on 22 Jun 2013 at 8:54

GoogleCodeExporter commented 9 years ago
Converted all the flags to be compatible with EFLAGS. You won't require a 
dictionary/lut anymore.
Thanks again, it was important IMO.

Original comment by distorm@gmail.com on 26 Jun 2013 at 10:31