question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

x86/64 lifting loop instruction

See original GitHub issue

Describe the bug The loop instruction contains unnecessary internal (intra) jumps as discussed in #15.

To Reproduce

0x19146D:    E2 FB                          loop -0x3 ; 0x19146A

By lifting the above instruction, we get:

-------------ISMark (19146D, 2)-------------
T_710:I32 := ECX
-------------LMark (Loop)-------------
T_710:I32 := (T_710:I32 - 0x1:I32)
if(T_710:I32 != 0x0:I32) then Jmp (Continue, 127) else Jmp (End, 128)
-------------LMark (Continue)-------------
EIP := (EIP + 0x19146A:I32)
Jmp (Loop, 126)
-------------LMark (End)-------------
-------------IEMark (19146F)-------------

Expected behavior The loop instruction in x86 should be handled the same as in jcc instructions. But currently we are treating loop in a particularly different way.

Additional context

See #15 for more discussion.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sijung07commented, May 30, 2019

Fixed in be647ce1d.

1reaction
sangkilccommented, May 31, 2019

Merged #19

Read more comments on GitHub >

github_iconTop Results From Across the Web

assembly - How exactly does the x86 LOOP instruction work?
You can't loop zero times, the CPU doesn't foresee loop instruction and somehow skip the body loop (the CPU cares only about current...
Read more >
LOOP/LOOPcc — Loop According to ECX Counter
Performs a loop operation using the RCX, ECX or CX register as a counter (depending on whether address size is 64 bits, 32...
Read more >
A Complete Formal Semantics of x86-64 User-Level ...
Our semantics faithfully formal- izes all the non-deprecated, sequential user-level instructions of the x86-64 Haswell instruction set ...
Read more >
Avoiding ISA Bloat with Macro-Op Fusion for RISC-V
by a memset loop. x86-64 utilizes a movdqa instruction ... 'lift' code out of a loop that returns the same value every iteration....
Read more >
Does a compiler use all x86 instructions? (2010)
Nearly all x86_64 instructions are microcoded on modern Intel and AMD ... "loop" instruction (compilers usually generate explicit loops for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found