News for hackers. Stuff that matters.
Re:Assembler Relaxation by SloopJon on Tuesday September 15, 2015 @03:19AM (#10219392)
I always kind of figured that the first pass would emit the most general form of a jump, then shorten it if possible, but I guess it works the other way around too.
Re:Assembler Relaxation by rer0tsaz on Tuesday September 15, 2015 @04:18AM (#10219529)
If you start with the most general form you won't always get an optimal solution, because two jumps may be blocking each other from optimizing. TASM does it that way. Consider (16-bit NASM):

  a:
  times 124 nop
  jmp b
  jmp a
  times 125 nop
  b:
Re:Assembler Relaxation by drudru11 on Tuesday September 15, 2015 @02:04PM (#10222177)
@SloopJon - I thought the same thing when I looked at this years ago. In fact, many older books/articles mentioned.

@rer0tsaz - this is a great counter example.

Is there a general form for these types of problems and solutions?

Also, I wonder how often instruction sequences like that would occur.