finding loops in disassembly

Nicolas Gloy <>
Thu, 27 Jul 1995 02:28:50 GMT

          From comp.compilers

Related articles
Finding loops in a disassembly (Max Domeika) (1995-07-22)
finding loops in disassembly (Nicolas Gloy) (1995-07-27)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Nicolas Gloy <>
Keywords: analysis, optimize, assembler
Organization: Compilers Central
References: 95-07-147
Date: Thu, 27 Jul 1995 02:28:50 GMT

Max Domeika <> writes:

      I'm trying to write a program to find loops in a disassembly
      listing. My program is able to form the CFG for a disassembly
      and I am now ready to attempt to find loops. I'm intending
      to use Algorithm 10.1 (pg. 604) in the Dragon book. Question(s):
      Are there any foreseeable problems in this besides indirect jumps?
      Is there a more efficient and reliable way to do this?


If you want your program to work on code generated from constructs
like "switch" in C, you have to add the edges between the indirect
jump and the targets of the switch. Otherwise, you would be left
with a whole bunch of missing edges, which would probably break the
loop -- assuming something like this:
while(cond) {
switch(foo) {
case 0: bar(); break;
case 1: qux(); break;
Typically (at least in the Alpha code I have looked at) the target
for the indirect jump is obtained by loading a value from a table
for that switch construct and adding it to some base value.
So you have to figure out the address of the table, read it from
the object file, and figure out the base address.
Maybe in the code that you're dealing with, the value loaded from
the table is the jump target (which makes things easier).
Good Luck !

Nicolas Gloy Harvard University Division of Applied Sciences Computer Architecture + Compilers

Post a followup to this message

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