2

I'm working on a project for school and I cannot find anything on the what JL means in at&t syntax. For reference, the question is to find the value of %eax when NOP runs. Here is the code it's used in:

MOV $492,%ebx
MOV $2494,%eax
MOV $28063,%ecx
CMP %eax,%ebx
JL L1
JMP L2
L1:
IMUL %eax,%ebx
ADD %eax,%ebx
MOV %ebx,%eax
SUB %ecx,%eax
JMP L3
L2:
IMUL %eax,%ebx
SUB %eax,%ebx
MOV %ebx,%eax
ADD %ecx,%eax
L3:
NOP

Also I would appreciate what JMP does as well as how the addition/subtraction/multiplication works (ADD/SUB/IMUL). I don't want to cheat, I just want to understand what's happening. For example, do you change the first number or the second when using math? Thank you all so much for helping.

DanielGibbs
  • 9,910
  • 11
  • 76
  • 121
Ella
  • 103
  • 2
  • 8

3 Answers3

12

Unfortunately, I can't comment due to low reputation. However, the above answers are not fully correct.

The information that the code is given in AT&T syntax is crucial to give the correct answer, since the operands are switched in AT&T syntax. In fact, what the code

CMP %eax,%ebx
JL L1

interpreted in AT&T syntax does is: "If the contents of EBX are less than the contents of EAX, jump to the label L1" - and not the other way round as mentioned before.

Pedro
  • 842
  • 6
  • 16
2

jl (jump on less than, signed) wiki

incogn1to
  • 429
  • 4
  • 17
-1

That is assemply language , JL is Jump if Less

This also works in x86 assembly language.

 CMP %eax,%ebx 
 JL L1

We compare EAX to EBX, then we'll jump to L1 depending on that comparison.

More specific - If the contents of EAX are less than the contents of EBX, jump to the label L1

See - Assembly - JG/JNLE/JL/JNGE after CMP

Community
  • 1
  • 1
Caffeinated
  • 11,982
  • 40
  • 122
  • 216
  • 1
    That makes sense, but how does it jump is %eax is more or if %ebx is more? – Ella Nov 17 '14 at 21:40
  • 1
    Will it jump to L1 if %eax is more or if %ebx is more? – Ella Nov 17 '14 at 21:41
  • @Ella - we say "less than the contents of EBX," means , EBX right ? – Caffeinated Nov 17 '14 at 21:46
  • @Ella - It's been a while for me, since I touched ASM – Caffeinated Nov 17 '14 at 21:46
  • 5
    @Coffee: Now that I have enough reputation to write a comment: Could you please correct your sentence "More specific - If the contents of EAX are less than the contents of EBX, jump to the label L1"? In AT&T syntax it is exactly the other way round, and OP explicitly asked for AT&T syntax. See my answer to this question. – Pedro Dec 06 '17 at 09:38