The Rearranger

Here is a program that rearranges assembly language so that it becomes structured, making use of Maurer’s theory of loop trees.
The rearranged program has exactly the same flow graph as the original program; it is not merely an equivalent program (which might be slower).
You can use this page to rearrange programs written in any of five assembly languages, as indicated below.
When you choose a language by clicking on its button:
The five languages are: IBM mainframe Pentium-compatible Motorola 68000 series G3, G4, or G5 MIPS (Silicon Graphics)
ASSEMBLER DESCRIPTION:

Once you have clicked on a language, you may now rearrange one of your own programs, written in that language.
If you wish to do this, type it (or copy and paste it) into the white ORIGINAL PROGRAM box, below (scrolling down, if necessary).
You may also rearrange our example program (a variant of depth-first search). In that case:
  • Wait for a new window (containing data) to open.
  • Choose Select All from your Edit menu.
  • Choose Copy from your Edit menu.
  • Close the new window.
  • Click in the white ORIGINAL PROGRAM box below.
  • Choose Paste from your Edit menu.
ORIGINAL PROGRAM:

To rearrange this program, and wait a few seconds.
The executable statements (only) of the original program should appear above, with line numbers.
The rearranged program should appear below, with line numbers corresponding to those above.

REARRANGED PROGRAM:

The rearranged program may now be copied and pasted back into your own files. To do this:
  • Click anywhere in the white REARRANGED PROGRAM box above.
  • Choose Select All from your Edit menu.
  • Choose Copy from your Edit menu.
  • Click in the window (in your own files) where you want the rearranged program.
  • Choose Paste from your Edit menu.
After copying and pasting, convert the result back to a monospaced font to see its original spacing.