How to optimize Intel's JMP instruction?

"Li Ping" <li_ping@hotmail.com>
24 Jul 2002 02:17:02 -0400

          From comp.compilers

Related articles
How to optimize Intel's JMP instruction? li_ping@hotmail.com (Li Ping) (2002-07-24)
Re: How to optimize Intel's JMP instruction? rveldema@cs.vu.nl (R.S. Veldema) (2002-07-25)
| List of all articles for this month |
From: "Li Ping" <li_ping@hotmail.com>
Newsgroups: comp.compilers
Date: 24 Jul 2002 02:17:02 -0400
Organization: http://groups.google.com/
Keywords: optimize, question
Posted-Date: 24 Jul 2002 02:17:02 EDT

This problem seems more complex than I thought. A good
compiler/assembler should use the short jump instruction whenever
possible. However, it's not as easy as it appears. Because there could
be other optimizable JMP instructions between this one and the target
label.


Here's an example. This is an excerpt from a list file produced by
MASM 6.15. This assembler always chooses the shortest possible
encoding for each JMP truction. In the example below, it's the 2nd JMP
instruction.


00000000 @2:
org $+3
00000003 E9 00000081 jmp @1
00000008 EB 7F jmp @1
org $+118
00000080 E9 FFFFFF7B jmp @2
org $+4
00000089 @1:


Question: How could a compiler/assembler optimize the JMP instruction?
Algorithm, data structures?


Thanks,
[See the comp.compilers archives. This is a well-studied problem. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.