• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

Understanding assembler instructions

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
b3n_
Asked:
b3n_
  • 4
1 Solution
 
Infinity08Commented:
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
 
Infinity08Commented:
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
 
b3n_Author Commented:
so in other words setnle would set dl if esi > eax?
0
 
Infinity08Commented:
>> 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
 
Infinity08Commented:
setnle is the same as setg btw.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now