Solved

# Understanding assembler instructions

Posted on 2007-07-25
479 Views
Hello,

i got some assembler instruction where im not exactly sure what they do:

text:100043B7                 cmp     esi, eax
text:100043B9                 setnle  dl

---------------

text:10004570                 cmp     esi, eax
text:10004572                 setl    cl

could someone give examples (with numbers) in which cases the flag would be set and in which cases not? in what order is the comparison done, esi or eax first?

Thank you.
0
Question by:b3n_

LVL 53

Expert Comment

setnle sets the byte if the result was not less or equal (or un-sets it if not)
setl sets the byte if the result was less (or un-sets it if not)

cmp compares the values in the two registers. If I'm not mistaken, it does that by subtracting the second value from the first, and then checks the sign (or for 0).
0

LVL 53

Expert Comment

So, this :

text:100043B7                 cmp     esi, eax
text:100043B9                 setnle  dl

is somewhat equivalent to (C-like syntax) :

if (!(esi <= eax)) dl = 1;
else dl = 0;

or simplified :

if (esi > eax) dl = 1;
else dl = 0;

and this :

text:10004570                 cmp     esi, eax
text:10004572                 setl    cl

is somewhat equivalent to (C-like syntax) :

if (esi < eax) dl = 1;
else dl = 0;
0

Author Comment

so in other words setnle would set dl if esi > eax?
0

LVL 53

Expert Comment

>> so in other words setnle would set dl if esi > eax?

Exactly. If esi > eax, it would set dl to 1, and if esi <= eax, it would set dl to 0.
0

LVL 53

Accepted Solution

setnle is the same as setg btw.
0

## Featured Post

### Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…