News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DIV Problem

Started by TBBW, November 22, 2010, 10:11:35 PM

Previous topic - Next topic

TBBW

Hello all,

for study I'm analyzing the following piece of code;

.
.
.
XOR EDX,EDX
DIV EDI
INC ESI
CMP ESI,10
JNZ
.
.

to put it in words;
the XOR resets the register  EDX to 00000000
the DIV EDI does a divson and puts a value in EAX and a value in EDX
INC ESI increases the ESI register by one like in C; i++
the CMP makes the compare, like a do while in C (in combi with JNZ)

so far I understand, but

the outcome of the DIV EDI is different every pass.......
the value of EDI is 00000010

is this a way to create a random number or something like that?

regards,

ger

clive

Or converting a binary number to hexadecimal. Where is this code from?
It could be a random act of randomness. Those happen a lot as well.

Gunther

Hi TBBW,

Quote from: TBBW, November 22, 2010, at 10:11:35 PMthe outcome of the DIV EDI is different every pass.......

That might be. The interesting question is: What's the value in EAX? DIV EDI divides the value in EAX by the value in EDI; after that the quotient is in EAX while EDX contains the remainder. Could you post the entire code please?

Gunther
Forgive your enemies, but never forget their names.

dedndave

DIV reg32 divides the 64-bit value in EDX:EAX by the value in reg32 (in this case, reg32 is EDI)
result: quotient in EAX and remainder in EDX

also
we see no use of ESI in the example shown, except that it is incremented
but, i am guessing the code before that shown is...
        mov     eax,[esi]
if that is the case, and you want to increment the index to the next dword, it should be
        add     esi,4
each dword consumes 4 bytes, so you want to adjust the address by 4, not by 1

BogdanOntanu

Read the rule of this forums :D  http://www.masm32.com/board/index.php?topic=31.0

Reversing other people's code is NOT allowed here... Not even for "learning purposes".

In consequence answer this question: Where is that code from? :D

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

hutch--

Against my better judgement I have unlocked this topic for one reason, to give the new member a chance to tell us what the code is for and where it is from. When we ask questions like this it is because we have been stung many times by new members trying to feed us bullsh*t so they can learn how to crack code or write viruses and similar. To keep the crap out of here we are forced to shoot first and ask questions later.

Tell us clearly what you are doing and if its OK we will alow the questions to continue, fail to tell us again and the topic is dead.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php