Performing Assembler "IDIV" opcode with python

75 Views Asked by At

I am trying to implement some assembly code with python. I have the following code -

00DF26C7  |. B9 0C000000    MOV ECX,0C
00DF26CC  |. F7F9           IDIV ECX

and my registers are -

EAX FFFFFEB0
ECX 0000000C
EDX FFFFFFFF
EBX 003CF000
ESP 0053F858
EBP 0053F860
ESI 00000000

If EAX is a positive number, then the following python code have exactly the same output as the opcode -

int(eax / 0x0c) & 0xffffffff

but I can't make it work for a negative eax... from my understanding the idiv opcode uses EDX:EAX, so 0xFFFFFFFFFFFFFEB0 / 0x0c, but even when trying this way I get a wrong result.

Maybe someone know how to implement this opcode? P.S. the correct result is - 0xFFFFFFE4

0

There are 0 best solutions below